fix(rest/python): match discount codes case-insensitively#128
Merged
carolinerg1 merged 1 commit intoJul 13, 2026
Merged
Conversation
damaz91
self-requested a review
July 13, 2026 12:44
The discount spec says codes are matched case-insensitively by business (docs/specification/discount.md, Operations -> Request behavior), but the server looked codes up by exact primary key, so the seeded 10OFF was not applied when a buyer submitted 10off. get_discount / get_discounts_by_codes now compare on func.upper(); the applied entry echoes the canonical stored code. Adds an integration test asserting a lowercase submission applies the uppercase-seeded discount.
damaz91
force-pushed
the
fix/discount-case-insensitive
branch
from
July 13, 2026 12:59
2d8d59c to
c14ef29
Compare
Contributor
|
Great fix, thanks for the help @vishkaty ! |
damaz91
approved these changes
Jul 13, 2026
carolinerg1
approved these changes
Jul 13, 2026
carolinerg1
merged commit Jul 13, 2026
14756f9
into
Universal-Commerce-Protocol:main
13 checks passed
This was referenced Jul 15, 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
docs/specification/discount.md(Operations → Request behavior) says:The server looked codes up by exact primary key (
get_discount→session.get(Discount, code), andget_discounts_by_codes→.in_(codes)), with no normalization. The seed data is uppercase (test_data/flower_shop/discounts.csv:10OFF,WELCOME20,FIXED500), so a buyer submitting10offgot no discount.On the seeded flower shop (bouquet_roses, 3500), same checkout differing only in the code's case:
discounts.applied10OFF["10OFF"]10off[]Fix
Compare on
func.upper()in both discount lookups; the applied entry echoes the canonical stored code. A code that is already the correct case is unaffected.Test
Adds an integration test that seeds
10OFFand submits10off: before the fix nothing is applied; after, the discount applies (assertsapplied == ["10OFF"]and a 10% discount total). Fullintegration_test.pystays green (6 passed),ruff check/ruff format --checkclean. Verified against the lastmain-compatible python-sdk commit (f54858e).Note (separate, happy to follow up)
The spec's Response behavior also says rejected codes are communicated via
messages[]; today an unmatched code is dropped silently. I kept this PR to the case-insensitivity fix to stay single-concern, but I'm glad to send a small follow-up adding amessages[]entry for rejected codes if that's welcome.