Skip to content

Commit 678f7f4

Browse files
authored
[stripe] Return NotFound for non-existent attribution IDs (#16600)
1 parent 5317b53 commit 678f7f4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

components/server/ee/src/user/stripe-service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
stripeClientRequestsCompletedDurationSeconds,
1515
} from "../../../src/prometheus-metrics";
1616
import { BillingServiceClient, BillingServiceDefinition } from "@gitpod/usage-api/lib/usage/v1/billing.pb";
17+
import { ResponseError } from "vscode-ws-jsonrpc";
18+
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
1719

1820
@injectable()
1921
export class StripeService {
@@ -57,7 +59,10 @@ export class StripeService {
5759
async getPortalUrlForAttributionId(attributionId: string, returnUrl: string): Promise<string> {
5860
const customerId = await this.findCustomerByAttributionId(attributionId);
5961
if (!customerId) {
60-
throw new Error(`No Stripe Customer ID found for '${attributionId}'`);
62+
throw new ResponseError(
63+
ErrorCodes.NOT_FOUND,
64+
`No Stripe Customer ID for attribution ID '${attributionId}'`,
65+
);
6166
}
6267
const session = await reportStripeOutcome("portal_create_session", () => {
6368
return this.getStripe().billingPortal.sessions.create({

0 commit comments

Comments
 (0)