Repository navigation
fix(app): preserve deleted workflow apps - #4932
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (8)
📒 Files selected for processing (29)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThe change separates app metadata from operations, adds deleted-app implementations, soft-deletes Stripe records while clearing secrets, preserves historical identities, and updates invoice synchronization and deletion behavior for deleted apps. ChangesDeleted app lifecycle
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to The change preserves deleted workflow app identity and provides deterministic handling for billing and provider operations; no actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant StripeApp
participant StripeAdapter
participant BillingWorkflow
participant InvoiceAPI
StripeApp->>StripeAdapter: uninstall app
StripeAdapter->>StripeAdapter: clear secrets and set DeletedAt
InvoiceAPI->>StripeAdapter: request deleted app data
StripeAdapter-->>InvoiceAPI: return preserved metadata
BillingWorkflow->>StripeApp: validate invoice workflow
StripeApp-->>BillingWorkflow: return deleted-app validation issue
BillingWorkflow-->>InvoiceAPI: record failure or cleanup warning
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Root cause
Invoice reads and advancement resolved the workflow app by instantiating its provider implementation. Stripe uninstallation hard-deleted the provider subtype row, so invoices retaining that historical app reference failed during app construction before billing could record a validation issue or enter the appropriate failed state.
Behavior
Deleted apps retain their ID, type, and public metadata. Generic operations return
app.ErrAppDeleted; invoicing operations return critical billing validation issues. External invoice deletion remains available and records a warning when provider cleanup must be skipped.Stripe uninstallation now preserves the subtype row, sets
deleted_at, and clears both secret references in one database update. Active rows require both references and deleted rows disallow them through a database check constraint.The migration down path requires purging soft-deleted Stripe subtype rows or reconstructing both valid secret references before restoring
NOT NULL.Validation
POSTGRES_HOST=127.0.0.1 go test -tags=dynamic ./openmeter/app/... ./openmeter/billing/... ./test/app/stripenix develop --impure .#ci -c make migrate-checknix develop --impure .#ci -c make lint-go-fastMaintenance task; no Jira ticket.
Summary by CodeRabbit
Greptile Summary
The PR preserves deleted workflow-app identities while replacing provider behavior with deterministic unavailable operations.
Confidence Score: 5/5
The PR appears safe to merge with no actionable correctness or security failures identified.
Production factories consistently install active or deleted operation implementations, Stripe credential removal is atomic and database-constrained, and the added lifecycle regressions cover historical reads, failed advancement, and invoice deletion.
Important Files Changed
Sequence Diagram
sequenceDiagram participant API as App/Billing caller participant Apps as App service participant Factory as Provider factory participant DB as PostgreSQL participant Billing as Invoice lifecycle API->>Apps: Resolve historical app ID Apps->>DB: Load soft-deleted AppBase Apps->>Factory: NewApp(deleted AppBase) Factory->>DB: Load retained provider metadata Factory-->>Apps: App identity + unavailable operations Apps-->>API: Resolvable deleted app Billing->>Apps: Resolve invoice workflow app Billing->>Factory: Invoke invoicing operation Factory-->>Billing: Deleted-app validation issue alt Invoice advancement Billing->>Billing: Enter failed lifecycle state else Invoice deletion Billing->>Billing: Delete invoice and record warning endReviews (1): Last reviewed commit: "fix(app): preserve deleted workflow apps" | Re-trigger Greptile
Context used (3)