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 validation error for nested array when requires => optional => requires #2128

Merged
merged 2 commits into from
Nov 5, 2020

Conversation

dwhenry
Copy link
Contributor

@dwhenry dwhenry commented Nov 4, 2020

This bug is due to the params parsing code return {} when the value is not found.
This is fine in most cases, however in the instance that the value was optional
and has nested required values.

I was not able to find a way to confine the changes to just the parameter parsing
as this resulted in the indexing being incorrect if any of the other array objects
had an error.

I have used a class to indicate that an Optional Value was missing as this avoid issues
with the value actually being in the response.

…> `requires`

This bug is due to the params parsing code return `{}` when the value is not found.
This is fine in most cases, however in the instance that the value was optional
and has nested required values.

I was not able to find a way to confind the changes to just the parameter parsing
as this resulted in the indexing being incorrect if any of the other array objects
had an error.

I have used a class to indicate that an Optional Value was missing as this avoid issues
with the value actually being in the response.
@dblock
Copy link
Member

dblock commented Nov 5, 2020

Looks like there are some legit spec failures here ...

cc: @stanhu @dm1try @dnesteryuk who dealt with params recently to add some comments

# are the parameter parsing stage as they are required to ensure
# the correct indexing is maintained
def skip?(val)
# return false
Copy link
Member

Choose a reason for hiding this comment

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

remove

@dblock
Copy link
Member

dblock commented Nov 5, 2020

Try writing more specs with other combinations of required parameters inside optional ones? I suspect we have similar problems with hash parameters and combinations of arrays and hashes.

…onents

This adds a number of tests around edge cases and different structures
that could result in the previous validation incorrectly reporting
missing data as a result of an optional element not being present.
@dwhenry
Copy link
Contributor Author

dwhenry commented Nov 5, 2020

@dblock added tests for all the edge cases that I believe this would affect and they all pass with this change. Let me know if you can think of anything else it would be worth testing.

@dblock
Copy link
Member

dblock commented Nov 5, 2020

i'm merging this

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

Successfully merging this pull request may close these issues.

2 participants