Skip to content

Commit bfb9ddf

Browse files
committed
fix(webapp): stop unrelated org flag saves from pinning the run-ops mint kind
stampMintKindFlip injected the default mint kind into every org feature-flag save, so an unrelated flag change wrote an explicit per-org runOpsMintKind override, pinning the org to that kind and making a later global flip silently skip it. Only stamp when the save actually sets runOpsMintKind.
1 parent 16df23f commit bfb9ddf

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

apps/webapp/app/v3/runOpsMigration/mintFlipGrace.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,17 @@ describe("stampMintKindFlip", () => {
134134
expect(result.runOpsMintKindFlippedAt).toBe(new Date(now).toISOString());
135135
});
136136

137-
it("defaults outgoing kind to 'cuid' when runOpsMintKind is absent", () => {
137+
it("leaves runOpsMintKind untouched when the save omits it (unrelated flag change: no inject, no spurious flip)", () => {
138138
const existing = { runOpsMintKind: "runOpsId" };
139-
const outgoing: Record<string, unknown> = {};
139+
const outgoing: Record<string, unknown> = { someOtherFlag: true };
140140
const result = stampMintKindFlip(existing, outgoing, T, GRACE_MS);
141141

142-
expect(result.runOpsMintKind).toBe("cuid");
143-
expect(result.runOpsMintKindPrev).toBe("runOpsId");
144-
expect(result.runOpsMintKindFlippedAt).toBe(new Date(T).toISOString());
142+
// Must not inject a default kind or stamp a flip: doing so would pin the org to an explicit
143+
// per-org override and make a later global flip silently skip it.
144+
expect(result.runOpsMintKind).toBeUndefined();
145+
expect(result.runOpsMintKindPrev).toBeUndefined();
146+
expect(result.runOpsMintKindFlippedAt).toBeUndefined();
147+
expect(result.someOtherFlag).toBe(true);
145148
});
146149

147150
it("treats a malformed existing flippedAt as no stamp", () => {

apps/webapp/app/v3/runOpsMigration/mintFlipGrace.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ export function stampMintKindFlip(
7575
nowMs: number,
7676
graceMs: number
7777
): Record<string, unknown> {
78+
// Only act when the save actually SETS runOpsMintKind. Omitting it (an unrelated flag change)
79+
// must not inject the default kind, which would pin the org and make a later global flip skip it.
80+
const outgoingKind = readMintKind(outgoingFlags, "runOpsMintKind");
81+
if (outgoingKind === undefined) {
82+
return outgoingFlags;
83+
}
7884
const storedKind = readMintKind(existingFlags ?? {}, "runOpsMintKind") ?? DEFAULT_MINT_KIND;
79-
const outgoingKind = readMintKind(outgoingFlags, "runOpsMintKind") ?? DEFAULT_MINT_KIND;
80-
outgoingFlags.runOpsMintKind = outgoingKind;
8185

8286
if (outgoingKind !== storedKind) {
8387
// Genuine target change: serve the currently-effective kind through the new grace window.

0 commit comments

Comments
 (0)