Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combined schema (anyOf, allOf, oneOf) error message enhancement #97

Open
cognifloyd opened this issue Oct 29, 2018 · 6 comments
Open

combined schema (anyOf, allOf, oneOf) error message enhancement #97

cognifloyd opened this issue Oct 29, 2018 · 6 comments

Comments

@cognifloyd
Copy link
Member

cognifloyd commented Oct 29, 2018

I think this goes here, but if it goes on StackStorm/st2, I can file the issue there.
This issue is about improving the error message returned when a schema validation error occurs due to not matching a oneOf schema.

I ran an orquesta workflow and for the task transition I used the incorrect:

publish:
  message: foobar

instead of the correct:

publish:
  - message: foobar

Doing that gave me an error message like:

    {
      "spec_path": "tasks.validate_input.next[0].publish",
      "message": "{'error_message': 'wrong format for input param foobar: {{ ctx().foobar }}'} is not valid under any of the given schemas",
      "type": "syntax",
      "schema_path": "properties.tasks.patternProperties.^\\w+$.properties.next.items.properties.publish.oneOf"
    },

Then, I went to look up the schema to figure out what I did wrong, mistakenly guessing that it didn't like my use of Jinja. My error was passing in a dict instead of an array. Could the error message be improved to say what the options are when the schemaPath is oneOf? (in this case string or array of unique one item dicts)

@m4dcoder
Copy link
Collaborator

@cognifloyd We support two types of schema for publish 1) a string in the format k1=v1 k2=v2 and 2) a dictionary of key value pairs. That's the reason for the error reporting one of the schemas not being matched. This error is produced by json schema and a result of support of more than one schemas here. I will keep this issue open but at this point we don't have a solution for this unless we drop support of 1 from the schema.

@cognifloyd
Copy link
Member Author

cognifloyd commented Nov 1, 2018

I wouldn't recommend dropping support for either of those options. I'm not talking about just publish, but more generally about making the schema validation messages more useful. Instead, enhance the error message with a bit more info.

Maybe when the schema is something that takes combined schemas (eg oneOf, anyOf, allOf) embed that portion of the schema in the error message, so that users can see what the relevant options are without searching for the schema to see what the options are.

@cognifloyd
Copy link
Member Author

I don't know about the feasibility of enhancing the messages, as you are probably using some 3rd party validation library. But it would be helpful, so I opened this issue to put it on the radar.

@cognifloyd cognifloyd changed the title schema error messages combined schema (anyOf, allOf, oneOf) error message enhancement Nov 1, 2018
@nmaludy
Copy link
Member

nmaludy commented Nov 7, 2018

+1

@nmaludy
Copy link
Member

nmaludy commented Nov 7, 2018

@m4dcoder would it be possible to include the schema possibilities that it is trying to match against?

@PLPRASU
Copy link

PLPRASU commented Apr 27, 2022

i am also getting same error like this
message: '[{''instance_ids'': ''<%ctx(inids) %>''}] is not valid under any of the given schemas'
schema_path: properties.tasks.patternProperties.^\w+$.properties.input.oneOf
spec_path: tasks.ec2_satrt.input
type: syntax
so please give me answer to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants