Repository navigation
Conversation
A cart past its expires_at was still served by GET /carts/{id} and could still be converted into a checkout. cart.md (Get Cart) says an expired cart is not_found, but nothing read expires_at. Add is_cart_expired (expired from the instant expires_at is reached) and use it in get_cart and the cart-to-checkout conversion, which now answer with the existing 404 RESOURCE_NOT_FOUND envelope. Add tests for both paths, an unexpired control, and the exact expiry boundary.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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
A cart past its
expires_atwas still served byGET /carts/{id}and could still be converted into a checkout withPOST /checkout-sessions {"cart_id": ...}. Create Cart setsexpires_atseven days out, but nothing ever read it.Root cause
CartService.get_cartand the cart load inCheckoutService.create_checkoutonly checked that the stored cart exists.Spec
cart.md, Get Cart: "Returnsnot_foundif the cart does not exist, has expired, or was canceled." The same document says platforms SHOULD handlenot_foundwhen a cart expires or is canceled. Checked against tagv2026-04-08.Fix
A small
is_cart_expiredhelper treats a cart as expired from the instantexpires_atis reached (expires_at <= now); a cart with noexpires_atnever expires.get_cartand the cart-to-checkout conversion raise the existingResourceNotFoundError(404,RESOURCE_NOT_FOUNDin the UCP error envelope), the same answer a missing cart already gets. TheZsuffix is normalised so the parse also works on Python 3.10, which the package still supports.Regression coverage
In
cart_test.py:RESOURCE_NOT_FOUNDonGET /carts/{id}POST /checkout-sessionswith itscart_idanswers 404 and no checkout is created for itexpires_at; a cart with no expiry never expiresThe three expired-cart tests fail on
main(200 and 201 instead of 404).Validation
rest/python/server:uv run pytest, 363 passedruff checkandruff formatcleanOut of scope
Update and cancel on an expired cart, and returning an already-existing incomplete checkout for a cart, are unchanged.