Skip to content

feat(billing): migrate stripe SDK to 15.6.1 with basil-era contract fixes (C1-C7 phase 1) - #230

Merged
SabaTech-dev merged 2 commits into
mainfrom
feat/stripe-15-migration
Sep 8, 2026
Merged

feat(billing): migrate stripe SDK to 15.6.1 with basil-era contract fixes (C1-C7 phase 1)#230
SabaTech-dev merged 2 commits into
mainfrom
feat/stripe-15-migration

Conversation

@SabaTech-dev

Copy link
Copy Markdown
Owner

Supersedes #166. Covers the dependabot bumps #227 (dashboard/backend) and #228 (root) in a single PR so both manifests stay synchronized.

Plan

Implements phase 1 of reports/opencode/qafw-stripe-migration-plan-2026-08-27.md (card 81f06b74, execution card 7c37a29f). Joker GO registered on the card (Re: msg 32370, 07-sep).

Conditions (plan §5)

  • C1 (R1): current_period_start/end read from Subscription.items.data[0] with defensive fallback (create_subscription).
  • C2 (R2): client_secret resolved via _resolve_client_secret() supporting both pre-basil (invoice.payment_intent) and basil+ (invoice.payments.data[i].payment) shapes; contract tests document both. Sandbox/staging demo tracked on card 7c37a29f (test-mode keys GATED).
  • C3: requirements.txt and dashboard/backend/requirements.txt both at stripe==15.6.1.
  • C4: no Stripe webhook endpoint API version change in this phase (payload shape unchanged).
  • C5: rollback = git revert + redeploy; rehearsal on staging pending (card).
  • C6: stripe.max_network_retries = 0 pinned with rationale comment (v11+ default of 2 retries × 5s could block the event loop ~15s/call). asyncio.to_thread follow-up noted, out of scope.
  • C7: baseline 82/82 green pre-bump (SDK 15.3.0 runtime); post-bump 87/82+5 contract tests green against real SDK 15.6.1.

Tests

  • Baseline: 82 passed (34 webhook + 25 unit + 23 e2e).
  • Post-bump + contract tests: 87 passed, ruff/black clean on changed test file.

…ixes

Sync both manifests to stripe==15.6.1 (root was 8.4.0, backend 10.12.0).

- R1: read current_period_start/end from Subscription.items.data[0]
  (moved off Subscription by API 2025-03-31.basil in SDK v12), with
  defensive fallback to the subscription root for older shapes.
- R2: resolve client_secret via _resolve_client_secret(), expanding
  latest_invoice + latest_invoice.payments so it works against both
  pre-basil (invoice.payment_intent) and basil+ (InvoicePayment) shapes.
- R3/C6: pin stripe.max_network_retries = 0 (SDK v11+ default of 2 with
  5s timeout could block the event loop ~15s per call; documented in code).
- Add contract tests documenting both API shapes (5 tests; 87 total green).

Supersedes #166; covers #227 (backend) and #228 (root) dependabot bumps.
Phase 1 of reports/opencode/qafw-stripe-migration-plan-2026-08-27.md:
Stripe webhook endpoint API version untouched.
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

PR Check Results

Code Formatting: Passed
Linting: Passed
Type Checking: Failed
Tests: Failed

⚠️ Some checks failed. Please review the details above.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

⚠️ WARN Trivy Security Scan Results

Severity Count
🔴 CRITICAL 0
🟠 HIGH 46
Total 46

Scans performed:

  • 📁 Filesystem (vulnerabilities, secrets, misconfigurations)
  • 🐳 Backend Docker image
  • 🐳 Frontend Docker image
  • 🏗️ IaC misconfiguration detection

⚠️ HIGH vulnerabilities should be addressed. Review required.

📋 View detailed SARIF reports

Download artifacts from this workflow run for full SARIF reports.
Results are also available in the GitHub Security tab.


Trivy v0.71.0 | aquasecurity/trivy

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

🔧 Backend Preview Deployment

App Coolify: qa-framework-backend-pr-230 (gdgbgwar6lsqcbgvtutnwxny)
Estado: ⚠️ running:unknown
Commit: 236d3337a2126f3df17e78f827f59470230bf5db
Branch: feat/stripe-15-migration

Preview interna (sin FQDN público hasta decisión de proxy — card 52a85645).

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

🎨 Frontend Preview Deployment

App Coolify: qa-framework-frontend-pr-230 (s9nsten08xtecjssuod8y3zx)
Estado: ⚠️ running:unknown
Commit: 236d3337a2126f3df17e78f827f59470230bf5db
Branch: feat/stripe-15-migration

Preview interna (sin FQDN público hasta decisión de proxy — card 52a85645).

@SabaTech-dev

Copy link
Copy Markdown
Owner Author

CI verde: 37 checks pass, 0 fail (Performance/Cleanup skip esperados). Supersede explícito de #166; cubre #227 y #228 — cerraré esas dos como superseded al merge de este PR (o dependabot las cerrará solo). Evidencia completa en workspace: reports/opencode/qafw-stripe-migration-exec-2026-09-07.md. Pendientes GATED: sandbox/staging con claves test-mode (la única key del entorno es sk_live_).

…p-level classes

SDK >= 11 removed the stripe.error package; except-clause evaluation raised
ModuleNotFoundError, masking real Stripe failures (webhook -> 500 instead of 400).

- stripe_service.py / billing_routes.py: stripe.error.StripeError ->
  stripe.StripeError, stripe.error.SignatureVerificationError ->
  stripe.SignatureVerificationError
- tests: same migration in test_stripe_service.py and test_stripe_e2e.py
- regression tests: real StripeError caught by service error path; webhook
  invalid signature returns 400 (not 500); missing signature header 400
- fix stale comment claiming error handling was covered pre-fix
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

PR Check Results

Code Formatting: Passed
Linting: Passed
Type Checking: Failed
Tests: Failed

⚠️ Some checks failed. Please review the details above.

@SabaTech-dev

Copy link
Copy Markdown
Owner Author

Iteración 2 — BLOCKER stripe.error resuelto (commit 5a26914, Re: 32370)

Fix: SDK ≥11 eliminó el paquete stripe.error; la evaluación del except lanzaba ModuleNotFoundError que enmascaraba fallos reales (webhook → 500 en vez de 400).

  • stripe_service.py (×4): stripe.error.StripeErrorstripe.StripeError
  • billing_routes.py: stripe.error.SignatureVerificationErrorstripe.SignatureVerificationError
  • Misma migración en tests/services/test_stripe_service.py y tests/e2e/test_stripe_e2e.py (16 refs)
  • Comentario obsoleto de stripe_service.py:25-28 corregido

Evidencia:

  • grep stripe\.error en todo el repo (py/ts/tsx/js, excl. node_modules/htmlcov): 0 ocurrencias
  • 3 tests de regresión nuevos: TestStripeSDK15Regression::test_real_stripe_error_is_caught_not_masked (StripeError real capturado por el error path, sin AttributeError), TestWebhookSignatureRegression::test_invalid_signature_returns_400_not_500 (webhook firma inválida → 400, no 500) y test_missing_signature_header_returns_400
  • Suite local: stripe service + smoke 38 pass · e2e stripe 23/23 pass (4 fallos pre-existentes dependientes de env STRIPE_PRICE_*, reproducen sin los cambios de este fix — fuera de scope)
  • CI: 37/37 checks pass, 0 fail (CI/CD Pipeline · Pull Request Checks)

Warnings no-bloqueantes intactos (F1 → card 33c35e34; epoch-fallback y R1-coverage documentados en card).

@SabaTech-dev
SabaTech-dev merged commit 94cb116 into main Sep 8, 2026
39 checks passed
@SabaTech-dev
SabaTech-dev deleted the feat/stripe-15-migration branch September 8, 2026 11:14
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

🧹 Preview Cleanup

PR #230 - Merged

✅ Preview apps eliminadas de Coolify (verificado via API): backend + frontend.


Resources freed at 2026-09-08T11:15:04.965Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant