fix: webhook handler missing payment_status check, null metadata guard, and sync error handling #358
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/basketball-api#358
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type
bug
Lineage
Standalone fix for regressions from #351
Repo
forgejo_admin/basketball-api
User Story
As a platform operator, I need the Stripe webhook handler to correctly check payment_status before marking orders as paid, handle null metadata without crashing, and commit order status even if jersey sync fails, so that webhook processing is robust against edge cases.
What Broke
_handle_generic_order_completedinwebhooks.pyhas three bugs introduced by #351:payment_statuscheck — marks orders aspaidregardless of the Stripe session'spayment_statusfield.get("order_id")onNonemetadata raisesTypeErrorsync_player_jersey_from_orderraises, order status never commitsRepro Steps
payment_status: "unpaid"— order incorrectly marked paidmetadata: null— handler crashes with TypeErrorsync_player_jersey_from_orderraises, the order status commit is skippedExpected Behavior
paidwhenpayment_status == "paid"Environment
basketball-api main branch, post-merge of #351
Context
The
dict()conversion on Stripe objects in #351 introduced these edge cases.File Targets
src/basketball_api/routes/webhooks.py— fix handler logictests/test_checkout.py— add 4 edge case testsAcceptance Criteria
paidwhenpayment_status == "paid"sync_player_jersey_from_ordererrors are caught; order status still commitsTest Expectations
test_webhook_skips_fulfillment_when_payment_status_not_paidtest_webhook_skips_fulfillment_when_payment_status_missingtest_webhook_handles_null_metadatatest_webhook_commits_order_status_even_if_sync_failsConstraints
Checklist
Related
Fixes regressions from #351