[Bug]: "End now" on a subscription can return 404 although the subscription ended
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, node.js
Research direction
Read portals/api-portal/src/services/subscriptionService.js and portals/api-portal/src/services/billing/paymentEventService.js, then trace the immediate deletion path and the customer.subscription.deleted webhook. Reproduce the timing in the API Portal billing journey against the testbench Stripe mock. Done means an immediate end returns success whether the webhook or request removes the subscription row first.
Written by the indexing model from the issue text.
Description
Please select the area the issue is related to
DeveloperPortal
Please select the aspect the issue is related to
Aspect/API (API backends, definitions, contracts, interfaces, OpenAPI)
Description
Ending a paid subscription immediately ("End now", DELETE /api/v0.9/subscriptions/{id}?immediate=true) can return 404 "Subscription not found" even though the subscription was ended. The API Portal then shows "Failed to remove subscription: Not Found".
Two paths remove the same subscription row, and whichever runs second finds nothing:
- The request.
deleteSubscription(portals/api-portal/src/services/subscriptionService.js) ends the subscription with the payment provider (subscriptionBillingService.endInProvider,immediate: true), then removes the row itself in a transaction. IfremoveSubscriptionremoves nothing, it throws a 404. - The webhook. Cancelling the subscription makes the provider send
customer.subscription.deleted.paymentEventService(portals/api-portal/src/services/billing/paymentEventService.js, lines 75–76) reads the ended subscription and removes the same row throughsubscriptionService.removeSubscription.
When the webhook is processed before the request reaches its own removal, the request answers 404 for a subscription it did end.
Observed (UI suite, API Portal billing journey "a developer pays for a flat rate and a usage based plan, follows them and ends them", run against the testbench Stripe mock): https://github.com/wso2/api-platform/actions/runs/44452694997/job/135322505050
DELETE /api-portal/api/v0.9/subscriptions/2eaa99f9-…(cancel at period end):200 {"message":"Your subscription has been cancelled. You will retain access until Dec 19, 2026.","endsAt":"2026-12-19T04:02:49.000Z"}DELETE /api-portal/api/v0.9/subscriptions/2eaa99f9-…?immediate=true("End now"), 2 seconds later:404 {"status":"error","code":"RESOURCE_NOT_FOUND","message":"Not Found","errors":[{"message":"Subscription not found"}]}- The page shows "Failed to remove subscription: Not Found" where the journey expects "Subscription removed successfully!".
The body rules out a provider-side failure: an error from endInProvider (SubscriptionBillingError) is returned with its own code and no errors list. The 404 comes from the row being gone.
Expected
Ending a subscription immediately returns success once the subscription has ended, whichever path removes its row.
Steps to Reproduce
- In the API Portal, subscribe to an API on a flat-rate plan through checkout.
- On the subscription's page, choose to unsubscribe (cancel at period end).
- Choose "End now" and confirm.
- Intermittently, the request returns 404 and the page shows "Failed to remove subscription: Not Found", although the subscription is gone. In CI it depends on whether the provider's
customer.subscription.deletedwebhook is processed before the request removes the row.
Severity Level of the Issue
Severity/Minor (Minor functionality is broken. Doesn't need immediate attention)
Environment Details (with versions)
Current main. API Portal built from source and run by the UI suite (tests/framework, block api-portal-billing) against the testbench Stripe mock, in GitHub Actions.
- Dominant language
- Go
- Stars
- 85
- Forks
- 137
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 247
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from wso2/api-platform
-
Area/DeveloperPortal Aspect/UI Severity/Minor Type/Bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
wso2/api-platform#4369 ·
Maintainers usually reply within 1 day
-
[Bug]: host-rewrite policy documentation lists fewer allowed host characters than the policy acceptsOpenArea/Policies Aspect/Other Severity/Trivial Type/Bug
Difficulty 1/5 Under an hour Newbie friendliness 91/100
wso2/api-platform#4355 ·
Maintainers usually reply within 1 day
-
Area/Gateway Aspect/API Severity/Minor Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
wso2/api-platform#4348 ·
Maintainers usually reply within 1 day
-
Aspect/AI Aspect/API. Severity/Major
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
wso2/api-platform#4343 ·
Maintainers usually reply within 1 day
-
Area/Policies Aspect/Configuration Severity/Minor Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
wso2/api-platform#4330 ·
Maintainers usually reply within 1 day
All issues in wso2/api-platform
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Inconsistency between golang and cue in specPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
security
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Tencent/LoopForge#1087 · 1 comment ·
Maintainers usually reply within 1 day