Skip to content

Commit 871b993

Browse files
committed
fix(webapp): early-return reconcile when per-org basins disabled
Without this guard `reconcileBasinForOrg` would still call into `provisionBasinForOrg` / `reconfigureBasinForOrg`, which both no-op behind the feature flag, but the reconciler then logged "provisioned (paid upgrade)" and returned `{ kind: "provisioned" }`. Misleading on a cloud install where billing is wired but per-org basins are off — the logs claim work that didn't happen, and we paid for a billing API round-trip we couldn't act on. Bail at the top with `{ kind: "skipped", reason: "feature-disabled" }` so the result and the logs match the actual no-op behaviour.
1 parent 97eb08e commit 871b993

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

apps/webapp/app/services/realtime/streamBasinRetentionByPlan.server.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { logger } from "~/services/logger.server";
1818
import { getCurrentPlan, isBillingConfigured } from "~/services/platform.v3.server";
1919
import {
2020
defaultRetention,
21+
isPerOrgBasinsEnabled,
2122
provisionBasinForOrg,
2223
reconfigureBasinForOrg,
2324
} from "./streamBasinProvisioner.server";
@@ -60,7 +61,14 @@ export function retentionForPlanCode(code: string | null | undefined): string {
6061
}
6162

6263
type ReconcileResult =
63-
| { kind: "skipped"; reason: "billing-not-configured" | "org-not-found" | "free-no-basin" }
64+
| {
65+
kind: "skipped";
66+
reason:
67+
| "billing-not-configured"
68+
| "feature-disabled"
69+
| "org-not-found"
70+
| "free-no-basin";
71+
}
6472
| { kind: "provisioned"; retention: string }
6573
| { kind: "reconfigured"; retention: string }
6674
| { kind: "deprovisioned" };
@@ -96,6 +104,15 @@ export async function reconcileBasinForOrg(orgId: string): Promise<ReconcileResu
96104
return { kind: "skipped", reason: "billing-not-configured" };
97105
}
98106

107+
// Feature flag is the master switch for the whole per-org basin
108+
// pipeline — `provisionBasinForOrg` / `reconfigureBasinForOrg` both
109+
// no-op when it's off. Bail here so the reconcile log lines and
110+
// result kinds reflect reality (no "provisioned (paid upgrade)" log
111+
// for a no-op call), and skip the billing API round-trip entirely.
112+
if (!isPerOrgBasinsEnabled()) {
113+
return { kind: "skipped", reason: "feature-disabled" };
114+
}
115+
99116
const plan = await getCurrentPlan(orgId);
100117
if (plan === undefined) {
101118
throw new Error(

0 commit comments

Comments
 (0)