Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metadata: convert keys to lowercase in FromContext() (#4416)
- Loading branch information
Showing
1 changed file
with
49 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
32d5490
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is sucks,
FromIncomingContext
do breaking change.32d5490
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was merged more than 6 months ago. If this breaks something for you, can you please be more specific about what broke and in what way.
32d5490
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FromOutgoingContext
used to create a copy of metadata, allocating new slices for each value.Now it reuses those slices, appending values from
raw.added
each timeFromOutgoingContext
is called. If the slices have excess capacity, the original metadata map is updated.Both
FromOutgoingContext
andFromIncomingContext
are similarly affected. It's now possible to modify the metadata (using the return value) if the slices have excess capacity.Update Okay, the double append doesn't seem like an issue, exactly. Calling
append
on a slice doesn't change the original slice; it returns a new slice that may point to the same array on the heap.The other bug (modifying the result) is obviously easier to trigger. Though you could argue that you shouldn't manipulate the map directly:
32d5490
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for commenting!
That was an unexpected behavior change. Just made a PR to fix it: #5267
32d5490
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that before this change, the doc strings on these functions said explicitly not to make modifications to the map. So while there was a behavior change, nobody should have noticed if they were following the documentation. That said, we definitely messed up by forgetting to copy the slice when we removed that comment, hence the fix in #5267.