Skip to content

Commit 28b2343

Browse files
authored
Merge pull request #6641 from RealDiligent/feat/critical-issue-env-flag-trim-6635
fix(review): trim whitespace on three truthy env flag checks
2 parents 729254a + 7d9217e commit 28b2343

6 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/review/gittensor-wire.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { resolveManifestOnlyFeature } from "./feature-activation";
2020
* {@link gittensorEnabledRepoFullNames} short-circuits before reading a single manifest. Truthy follows the
2121
* codebase convention (`/^(1|true|yes|on)$/i`, same as isImpactMapEnabled / isSelfTuneEnabled). */
2222
export function isGittensorPluginEnabled(env: { LOOPOVER_EXPERIMENTAL_GITTENSOR?: string | undefined }): boolean {
23-
return /^(1|true|yes|on)$/i.test(env.LOOPOVER_EXPERIMENTAL_GITTENSOR ?? "");
23+
return /^(1|true|yes|on)$/i.test((env.LOOPOVER_EXPERIMENTAL_GITTENSOR ?? "").trim());
2424
}
2525

2626
/** Resolve whether the gittensor plugin is active for THIS repo: the operator's global env kill-switch AND an

src/review/maintainer-recap-wire.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function isRecapEnabled(
2828
manifestOverride?: MaintainerRecapManifestOverride | undefined,
2929
): boolean {
3030
if (manifestOverride?.present) return manifestOverride.enabled;
31-
return /^(1|true|yes|on)$/i.test(env.LOOPOVER_MAINTAINER_RECAP ?? "");
31+
return /^(1|true|yes|on)$/i.test((env.LOOPOVER_MAINTAINER_RECAP ?? "").trim());
3232
}
3333

3434
export type RecapCadence = "daily" | "weekly";

src/review/pr-reconciliation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function isPrReconciliationEnabled(
3737
manifestOverride?: PrReconciliationManifestOverride | undefined,
3838
): boolean {
3939
if (manifestOverride?.present) return manifestOverride.enabled;
40-
return /^(1|true|yes|on)$/i.test(env.LOOPOVER_PR_RECONCILIATION ?? "");
40+
return /^(1|true|yes|on)$/i.test((env.LOOPOVER_PR_RECONCILIATION ?? "").trim());
4141
}
4242

4343
// Short in-isolate TTL cache for resolvePrReconciliationManifestOverride, mirroring ops-wire.ts /

test/unit/gittensor-wire.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ describe("isGittensorPluginEnabled", () => {
3838
expect(isGittensorPluginEnabled({ LOOPOVER_EXPERIMENTAL_GITTENSOR: "on" })).toBe(true);
3939
expect(isGittensorPluginEnabled({ LOOPOVER_EXPERIMENTAL_GITTENSOR: "yes" })).toBe(true);
4040
});
41+
42+
it("REGRESSION (#6635): whitespace-padded truthy values still activate (matches isRagEnabled)", () => {
43+
expect(isGittensorPluginEnabled({ LOOPOVER_EXPERIMENTAL_GITTENSOR: "true\n" })).toBe(true);
44+
expect(isGittensorPluginEnabled({ LOOPOVER_EXPERIMENTAL_GITTENSOR: " 1 " })).toBe(true);
45+
expect(isGittensorPluginEnabled({ LOOPOVER_EXPERIMENTAL_GITTENSOR: "\ton\t" })).toBe(true);
46+
});
4147
});
4248

4349
describe("shouldEnableGittensorForRepo", () => {

test/unit/maintainer-recap-wire.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ describe("isRecapEnabled — default OFF, truthy convention", () => {
6868
for (const on of ["1", "true", "yes", "on", "TRUE", "On"]) expect(isRecapEnabled({ LOOPOVER_MAINTAINER_RECAP: on })).toBe(true);
6969
});
7070

71+
it("REGRESSION (#6635): whitespace-padded truthy values still activate (matches isRagEnabled)", () => {
72+
expect(isRecapEnabled({ LOOPOVER_MAINTAINER_RECAP: "true\n" })).toBe(true);
73+
expect(isRecapEnabled({ LOOPOVER_MAINTAINER_RECAP: " 1 " })).toBe(true);
74+
expect(isRecapEnabled({ LOOPOVER_MAINTAINER_RECAP: "\ton\t" })).toBe(true);
75+
});
76+
7177
it("a present manifest override wins outright over the env flag, in both directions (#2250)", () => {
7278
expect(isRecapEnabled({ LOOPOVER_MAINTAINER_RECAP: "false" }, { present: true, enabled: true, cadence: "weekly" })).toBe(true);
7379
expect(isRecapEnabled({ LOOPOVER_MAINTAINER_RECAP: "true" }, { present: true, enabled: false, cadence: "weekly" })).toBe(false);

test/unit/pr-reconciliation.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ describe("isPrReconciliationEnabled — default OFF, truthy convention", () => {
2121
for (const on of ["1", "true", "yes", "on", "TRUE", "On"]) expect(isPrReconciliationEnabled({ LOOPOVER_PR_RECONCILIATION: on })).toBe(true);
2222
});
2323

24+
it("REGRESSION (#6635): whitespace-padded truthy values still activate (matches isRagEnabled)", () => {
25+
expect(isPrReconciliationEnabled({ LOOPOVER_PR_RECONCILIATION: "true\n" })).toBe(true);
26+
expect(isPrReconciliationEnabled({ LOOPOVER_PR_RECONCILIATION: " 1 " })).toBe(true);
27+
expect(isPrReconciliationEnabled({ LOOPOVER_PR_RECONCILIATION: "\ton\t" })).toBe(true);
28+
});
29+
2430
it("a present manifest override wins outright over the env flag, in both directions (#6558)", () => {
2531
expect(isPrReconciliationEnabled({ LOOPOVER_PR_RECONCILIATION: "false" }, { present: true, enabled: true })).toBe(true);
2632
expect(isPrReconciliationEnabled({ LOOPOVER_PR_RECONCILIATION: "true" }, { present: true, enabled: false })).toBe(false);

0 commit comments

Comments
 (0)