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

Fix incorrect path selection for oneOf cases in jsonschema #10883

Merged
merged 2 commits into from
Mar 9, 2022

Conversation

jamakase
Copy link
Contributor

@jamakase jamakase commented Mar 6, 2022

What

Fixes a problem, when wrong validation schema path was selected for oneOf field. Closes #9980

How

For some reason when we were building validationSchema we were combining current path with property key ( so in oneOf case, instead of format.compression_codec it was format.format.compression_codec, as a result always first entry in oneOf was selected.

@github-actions github-actions bot added area/frontend area/platform issues related to the platform labels Mar 6, 2022
@jamakase jamakase marked this pull request as ready for review March 6, 2022 10:46
@jamakase jamakase requested a review from a team as a code owner March 6, 2022 10:46
@jamakase jamakase temporarily deployed to more-secrets March 6, 2022 10:48 Inactive
@jamakase jamakase temporarily deployed to more-secrets March 6, 2022 10:48 Inactive
@jamakase jamakase self-assigned this Mar 6, 2022
@jamakase jamakase temporarily deployed to more-secrets March 8, 2022 09:32 Inactive
@jamakase jamakase temporarily deployed to more-secrets March 8, 2022 09:32 Inactive
if (selectedSchema && typeof selectedSchema !== "boolean") {
return buildYupFormForJsonSchema(
{ type: jsonSchema.type, ...selectedSchema },
uiConfig,
jsonSchema,
propertyKey,
propertyPath ? `${propertyPath}.${propertyKey}` : propertyKey
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're having the same logic two times more further down. Once inside an object and once inside the array branch. For the object the propertyKey we're actually having is not the one passed into this method, but for array it's the same as passed into, and thus the logic the same as here. Could you please explain (and give some example schemas to illustrate it), why the logic needs adjustment in this place, but for the other two calls to buildYupFormForJsonSchema further down it's the correct behavior?

Copy link
Contributor Author

@jamakase jamakase Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we don't need it for oneOf case and need it for object and array cases, as we handle oneOf same way as object and array based on selected value, so we do not want to add propertyPath for oneOf cases. So we sort of try to get rid of oneOf and continue to working as with a usual schema. That's why we don't need it for oneOf.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timroes let me know if it's still unclear. I will try to provide a more accurate answer

Copy link
Contributor

@timroes timroes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, fixes the linked issue for me. Should this also close #8291 ?

@jamakase
Copy link
Contributor Author

jamakase commented Mar 9, 2022

Tested locally, fixes the linked issue for me. Should this also close #8291 ?

No, it is a bit different problem - I think that one is about state not being reset for oneOf case when you click cancel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Destination GCS: Set up destination button does nothing when setting up a destination with compression
2 participants