Repository navigation
price: reject negative inputs in Parse - #6031
Merged
Merged
Conversation
Parse accepted a leading minus but never checked the sign. Values below MinInt32 wrapped to a valid-looking positive price. Return ErrNoNegatives for any input starting with "-". Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The reviewed changes address the negative-input issue and include appropriate regression and validation coverage.
No open issues 🎉
What changed in this PR
This pull request updates price.Parse to reject negative inputs before conversion can produce invalid or wrapped xdr.Price values.
Changes:
- Removes leading-minus support from the price grammar.
- Returns
ErrNoNegativesfor inputs beginning with-. - Adds regression tests for negative values, wraparound cases, and successful parse validation.
| File | Summary |
|---|---|
price/main.go |
Rejects negative price inputs and updates the accepted grammar. |
price/main_test.go |
Tests negative-input rejection, wraparound cases, and output validation. |
Review effort: Lite
urvisavla
marked this pull request as ready for review
October 23, 2026 00:22
tamirms
approved these changes
Oct 23, 2026
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.
What
price.Parsenow returnsErrNoNegativesfor any input that starts with-. The grammar regexp no longer accepts a leading minus.-1{-1, 1}, no error (rejected later byValidate())ErrNoNegatives-2147483649{2147483647, 1}, passesValidate()ErrNoNegatives-2147483647.9{1, 10}, passesValidate()ErrNoNegativesWhy
Parseaccepted a leading minus but never checked the sign of the result:🤖 Generated with Claude Code