Skip to content

Improve DupMapKeyError message#670

Merged
fxamacker merged 1 commit intomasterfrom
fxamacker/improve-error-message
Jun 8, 2025
Merged

Improve DupMapKeyError message#670
fxamacker merged 1 commit intomasterfrom
fxamacker/improve-error-message

Conversation

@fxamacker
Copy link
Copy Markdown
Owner

Currently, DupMapKeyError uses hard-coded quotes in the error message for map keys, including non-string types.

Given this, an error message containing a quoted integer having a value of 1 looks the same as the string "1" because they both have quotes in the error message.

This PR removes the hard-coded quotes in the error message and replaces %v with %#v to only emit quotes when applicable.

NOTE: This change is only relevant for user apps that use the non-default DupMapKeyEnforcedAPF decoding option.

This commit is only relevant for user apps that use
the non-default DupMapKeyEnforcedAPF decoding option.

Currently, DupMapKeyError uses hardcoded quotes in the
error message for map keys, including non-string types.

Given this, an error message containing a quoted integer
having a value of 1 looks the same as the string "1"
because they both have quotes in the error message.

This commit removes the hardcoded quotes in the error message
and replaces %v with %#v to only emit quotes when applicable.
@fxamacker fxamacker self-assigned this Jun 8, 2025
@fxamacker fxamacker added the improvement improvement that does not add new feature label Jun 8, 2025
@fxamacker
Copy link
Copy Markdown
Owner Author

@x448 PTAL 🙏

Copy link
Copy Markdown
Contributor

@x448 x448 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@fxamacker fxamacker merged commit 3e7e036 into master Jun 8, 2025
22 checks passed
@fxamacker fxamacker added this to the v2.9.0 milestone Jul 5, 2025
@fxamacker fxamacker deleted the fxamacker/improve-error-message branch September 16, 2025 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement improvement that does not add new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants