fix: reject tag keys that end in a newline - #55
Open
Abhishek-B-R wants to merge 1 commit into
Open
Abhishek-B-R wants to merge 1 commit into
Abhishek-B-R wants to merge 1 commit into
Conversation
TAG_KEY_REGEX.match lets a key like "env\n" through, because re's $ also matches just before a trailing newline. The TypeScript and Go SDKs drop that key. Use fullmatch so the whole key has to match.
Member
|
Thanks for the PR :) |
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.
Problem
validate_tagschecks keys withTAG_KEY_REGEX.match(key). In Python,$also matches right before a trailing newline, so a key like"env\n"passes validation and gets sent:The TypeScript and Go SDKs use the same pattern but anchor the whole string, so they drop that key. #29 says the three SDKs follow the same rules, so Python is the odd one out.
Fix
Use
TAG_KEY_REGEX.fullmatch(key)instead of.match(key). Valid keys behave exactly as before.Tests
ruff checkreports the same count as main (258), so nothing new.