-
Notifications
You must be signed in to change notification settings - Fork 0
fix(attrs): use base-10 only for int parsing (#373) #24
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -192,6 +192,9 @@ func TestCliAttrsToOtel(t *testing.T) { | |
| "test 5 - bool, false": "false", | ||
| "test 6 - bool, True": "True", | ||
| "test 7 - bool, False": "False", | ||
| "test 8 - hex string": "0x0", | ||
| "test 9 - hex string2": "0xFF", | ||
| "test 10 - octal str": "0o777", | ||
|
Comment on lines
+196
to
+197
|
||
| } | ||
|
|
||
| otelAttrs := StringMapAttrsToProtobuf(testAttrs) | ||
|
|
@@ -228,6 +231,21 @@ func TestCliAttrsToOtel(t *testing.T) { | |
| if attr.Value.GetBoolValue() != false { | ||
| t.Errorf("expected value '%s' for key '%s' but got %t", testAttrs[key], key, attr.Value.GetBoolValue()) | ||
| } | ||
| case "test 8 - hex string": | ||
| // #373: 0x0 should be treated as a string, not parsed as hex int | ||
| if attr.Value.GetStringValue() != "0x0" { | ||
| t.Errorf("expected string value '0x0' for key '%s' but got parsed as different type", key) | ||
| } | ||
| case "test 9 - hex string2": | ||
| // #373: 0xFF should be treated as a string, not parsed as hex int | ||
| if attr.Value.GetStringValue() != "0xFF" { | ||
| t.Errorf("expected string value '0xFF' for key '%s' but got parsed as different type", key) | ||
| } | ||
| case "test 10 - octal str": | ||
| // 0o777 should be treated as a string, not parsed as octal int | ||
| if attr.Value.GetStringValue() != "0o777" { | ||
| t.Errorf("expected string value '0o777' for key '%s' but got parsed as different type", key) | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
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.
The PR description mentions binary-prefixed strings (e.g.,
0b1010) were also being parsed via base-0 autodetection, but the new tests only cover hex and octal. Add a test case asserting a0b...value remains a string to fully cover the stated behavior.