Real-Stripe integration tests leave orphan test-mode Price/Product objects #503
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#503
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 — discovered 2026-04-18 during QA review of PR #499. QA noted the new
tests/test_monthly_payment_link_real_stripe.py(and its older siblingtests/test_payment_link_real_stripe.pyfrom #494) do not clean up the test-mode Stripe objects they create.Repo
forgejo_admin/basketball-apiWhat Broke
Every CI run that executes a real-Stripe integration test leaves behind permanent artifacts in the test-mode Stripe account: a Product, a Price, a PaymentLink. They are not deactivated or archived after the assertion passes. Over weeks of CI runs the test-mode account accumulates thousands of orphans, which:
Repro Steps
git checkout mainBASKETBALL_STRIPE_TEST_API_KEYto the test-mode keypython -m pytest tests/test_monthly_payment_link_real_stripe.py tests/test_payment_link_real_stripe.pyExpected Behavior
After each real-Stripe integration test passes (or fails), a teardown fixture archives the created Product, deactivates the Price, and deactivates the PaymentLink. Test-mode account stays clean.
Environment
stripe==14.4.1python:3.12-slim) withBASKETBALL_STRIPE_TEST_API_KEYrepo secretBlast Radius
Test-only. No prod impact. But the orphans cost us dashboard clarity and will grow without bound.
Scope / Fix Direction
tests/conftest.pyor a per-file fixture) that tracks created Stripe ids and runs teardown infinally.stripe.PaymentLink.modify(id, active=False),stripe.Price.modify(id, active=False),stripe.Product.modify(id, active=False)(Products can't be hard-deleted if ever referenced; archiving via active=False is the supported path).Acceptance Criteria
yield+finallypattern, not try/except in test body)Retrievereturnsactive: falsefor the archived resourcesConstraints
Checklist
Related
forgejo_admin/basketball-api #494— tournament real-Stripe testforgejo_admin/basketball-api #498— monthly real-Stripe test