Skip to content

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.

@dwhenry dwhenry force-pushed the fix-nested-validations branch from 1714f21 to 33a57a9 Compare November 4, 2020 18:49
…> `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 dwhenry force-pushed the fix-nested-validations branch from 741ed9b to 2647e2c Compare November 5, 2020 16:35
@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