Open barmac opened 10 months ago
We could also make sure that the condition#property
value is one of the already existing property#id
s.
We could use $data
for this: https://json-schema.org/blog/posts/hyperborea#referencing-other-parts-of-the-schema
I experimented with $data
, and this is the result: https://github.com/camunda/element-templates-json-schema/compare/main...125-disallow-properties-depending-on-itself?body=&expand=1
The solution works but requires to enable $data: true
in the Ajv validator. The error message displayed in the editor is quite cryptic:
However, the cryptic error message can be adjusted thanks to the error-messages extension.
OK so actually the result from VSCode that I showed above is incorrect. VSCode does not handle $data
as in ajv, so it doesn't matter whether we implement the constraint in the JSON schema or programmatically in the validator.
Describe the Bug
Right now, the schema allows a property to depend on itself. Specifically, the
condition#property
can take any value, and this can also be theid
of the conditioned property. This leads to infinite loop which should be prevented via the JSON schema.Steps to Reproduce
Check the conversation: https://camunda.slack.com/archives/C0693F1NFK5/p1704872988839289
Expected Behavior
Template should be rejected by the validator.
Environment
Discovered via https://camunda.slack.com/archives/C0693F1NFK5/p1704872988839289