Fix Stripe SDK v15 webhook crash + add webhook Prometheus metrics #350
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#350
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
Root cause of all webhook delivery failures since basketball-api image was rebuilt with Stripe SDK v15.0.1. Discovered via end-to-end test on 2026-04-06. Related to forgejo_admin/basketball-api#343, #346. Supersedes forgejo_admin/basketball-api#719 (same root cause).
Repo
forgejo_admin/basketball-apiWhat Broke
Stripe SDK v15.0.1 removed
.get()fromStripeObject. The webhook handler atsrc/basketball_api/routes/webhooks.pyuses.get()in 23 places on Stripe event data (2 additional.get()calls are on Python dicts/SQLAlchemy and are fine). Every webhook delivery crashes withAttributeError: getat line 301+ before updating the database. Payment succeeds on Stripe's side, but the DB never updates — jersey orders stuck atpending.Confirmed via live $1 test payment on 2026-04-06: signature verified (new secret works), handler crashed, DB unchanged, Stripe got 500 back.
Root cause:
pyproject.tomlpinsstripe>=11.0with no upper bound. Docker image build resolved to15.0.1. Local dev has14.4.1(works). Deployed pod has15.0.1(crashes).Repro Steps
checkout.session.completedwebhookdata_object.get("metadata", {})on line 301 throwsAttributeError: getExpected Behavior
Webhook handler processes
checkout.session.completedevents without crashing. Player jersey records update automatically (option, size, number, status=paid)./metricsendpoint exposes webhook counters for platform alerting.Environment
15.0.114.4.1stripe>=11.0(no upper bound)Acceptance Criteria
stripe>=11.0,<15inpyproject.toml.get()calls on Stripe objects insrc/basketball_api/routes/webhooks.pyreplaced with bracket notation ordict()wrappingcheckout.session.completedprocesses without crash, DB updatesprometheus_clientadded topyproject.toml;/metricsexposeswebhook_received_total,webhook_processed_total,webhook_errors_total(by event_type),webhook_last_received_timestampRelated
project-westside-basketball— project this affectsforgejo_admin/basketball-api#340— original user reportforgejo_admin/basketball-api#343, #346 — earlier investigationforgejo_admin/basketball-api#719— superseded (same root cause)forgejo_admin/pal-e-platform#272(alerting depends on these metrics)src/basketball_api/routes/webhooks.py(23.get()calls),pyproject.toml(Stripe pin + prometheus_client dep),src/basketball_api/routes/health.pyor metrics module (Prometheus counters)Scope Review: NEEDS_REFINEMENT
Review note:
review-856-2026-04-04Template is complete and well-written. Five body-level fixes needed before dispatch:
src/basketball_api/routes/webhooks.py), addhealth.pyas targetprometheus_clientdependency to AC 4 scopearch-basketball-apidoes not exist in pal-e-docs -- needs creationScope Review: READY
Review note:
review-856-2026-04-04-r2Re-review after refinement. All 5 BODY fixes from previous review confirmed addressed: repo-root file paths, .get() count corrected to 23, prometheus_client in AC, #719 superseded in Lineage, AC 5 reworded.
arch-basketball-apistill needs creation (carried forward, does not block dispatch)