Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
A fun one. String coding keys that are valid integers were taking an unexpected codepath and lead to a crash due
to a broken invariant.
When parsing URIs (such as query items), the first value that's being decoded helps decide whether we'll treat
the collection as an array or a dictionary. If the coding key is a valid int, it's an array, otherwise a dictionary.
The problem is that string keys that are valid ints were getting converted successfully to ints, meaning that dictionaries
with int-like string keys were taking the wrong path.
Modifications
Don't auto-convert coding keys, instead pass explicit string/int keys in the keyed/unkeyed coder implementations.
Result
No more crash for a specially crafted query string.
Test Plan
Added unit tests for this, both on the encoding and the decoding side.