orquesta icon indicating copy to clipboard operation
orquesta copied to clipboard

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

Open cognifloyd opened this issue 6 years ago • 6 comments

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)

cognifloyd avatar Oct 29 '18 10:10 cognifloyd

@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.

m4dcoder avatar Oct 31 '18 19:10 m4dcoder

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 avatar Nov 01 '18 03:11 cognifloyd

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 avatar Nov 01 '18 03:11 cognifloyd

+1

nmaludy avatar Nov 07 '18 14:11 nmaludy

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

nmaludy avatar Nov 07 '18 14:11 nmaludy

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.

PLPRASU avatar Apr 27 '22 02:04 PLPRASU