[Bug]: "End now" on a subscription can return 404 although the subscription ended

Abierto
#4,368 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
javascript, node.js
Área
api, backend, payments

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Area/DeveloperPortal Aspect/API Severity/Minor Type/Bug
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:

  1. 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. If removeSubscription removes nothing, it throws a 404.
  2. 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 through subscriptionService.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
  1. In the API Portal, subscribe to an API on a flat-rate plan through checkout.
  2. On the subscription's page, choose to unsubscribe (cancel at period end).
  3. Choose "End now" and confirm.
  4. 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.deleted webhook 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.

Lenguaje dominante
Go
Estrellas
85
Forks
137
Merge medio
1 d 12 h
PR fusionados (30 d)
247

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de wso2/api-platform

Todos los issues de wso2/api-platform

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.