From 336295c0ab02b9a19d8fb9d84a754b41c7bc1f09 Mon Sep 17 00:00:00 2001 From: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Date: Tue, 3 Feb 2026 10:42:35 +0200 Subject: [PATCH] fix: suppress alerts for expected billing errors in increment-usage task (#27535) - Skip retrying and alerting for temp/sandbox subscription IDs - Skip retrying and alerting for non-usage-based subscriptions - Log expected errors at info level instead of error level Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../billing/tasker/trigger/increment-usage.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/features/ee/organizations/lib/billing/tasker/trigger/increment-usage.ts b/packages/features/ee/organizations/lib/billing/tasker/trigger/increment-usage.ts index 9101925d16..f7abc9641a 100644 --- a/packages/features/ee/organizations/lib/billing/tasker/trigger/increment-usage.ts +++ b/packages/features/ee/organizations/lib/billing/tasker/trigger/increment-usage.ts @@ -5,6 +5,30 @@ import { INCREMENT_USAGE_JOB_ID } from "../constants"; import { platformBillingTaskConfig } from "./config"; import { platformBillingTaskSchema } from "./schema"; +/** + * Checks if an error is expected and should not trigger alerts. + * Expected errors include: + * - Subscriptions with "temp" or "sandbox" in the ID (test/placeholder subscriptions) + * - Subscriptions that are not usage-based (this task only handles usage-based subscriptions) + */ +function isExpectedBillingError(error: unknown): boolean { + if (!(error instanceof Error)) return false; + + const message = error.message.toLowerCase(); + + // Check for temp/sandbox subscription IDs in "No such subscription" errors + if (message.includes("no such subscription")) { + return message.includes("temp") || message.includes("sandbox"); + } + + // Check for non-usage-based subscription errors + if (message.includes("is not usage based")) { + return true; + } + + return false; +} + export const incrementUsage: TaskWithSchema = schemaTask({ id: INCREMENT_USAGE_JOB_ID, @@ -19,6 +43,11 @@ export const incrementUsage: TaskWithSchema