Skip to content

Commit f31612f

Browse files
committed
fix: compare task intervals numerically in diagnostics
docker-entrypoint.sh writes env-provided APP.TASKS intervals back to config.yaml as quoted YAML strings, so a value equal to the numeric shipped default (e.g. "120" vs 120) was reported as drift by collectNonDefaultTaskIntervals. Compare numerically when both sides parse as finite numbers, falling back to strict equality otherwise.
1 parent 1a9ff65 commit f31612f

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/routes/diagnostics.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,18 @@ const collectNonDefaultTaskIntervals = (actualTasks, defaultTasks = defaultConfi
363363
for (const key of TASK_INTERVAL_KEYS) {
364364
const defaultValue = defaultTasks?.[key];
365365
const actualValue = actualTasks?.[key];
366-
if (actualValue === undefined || actualValue === defaultValue) continue;
366+
if (actualValue === undefined) continue;
367+
// docker-entrypoint.sh writes env-provided intervals back as quoted YAML
368+
// strings, so a config value can equal the numeric default semantically
369+
// ("120" vs 120). Compare numerically when both parse as finite numbers,
370+
// falling back to strict equality otherwise.
371+
const defaultNum = Number(defaultValue);
372+
const actualNum = Number(actualValue);
373+
const isEqual =
374+
Number.isFinite(defaultNum) && Number.isFinite(actualNum)
375+
? defaultNum === actualNum
376+
: actualValue === defaultValue;
377+
if (isEqual) continue;
367378
nonDefault.push({ key, default: defaultValue, actual: actualValue });
368379
}
369380
return nonDefault;

tests/v2/integration/diagnostics-helpers.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,4 +625,21 @@ describe('diagnostics collectNonDefaultTaskIntervals', function () {
625625
};
626626
expect(collectNonDefaultTaskIntervals(actual, defaultTasks)).to.deep.equal([]);
627627
});
628+
629+
it('treats numeric-string intervals equal to the default as default', function () {
630+
// docker-entrypoint.sh writes env-provided intervals as quoted YAML strings.
631+
const actual = {
632+
...defaultTasks,
633+
GOVERNANCE_SYNC_TASK_INTERVAL: '120',
634+
MIRROR_CHECK_TASK_INTERVAL: '900',
635+
};
636+
expect(collectNonDefaultTaskIntervals(actual, defaultTasks)).to.deep.equal([]);
637+
});
638+
639+
it('still reports numeric-string intervals that differ from the default', function () {
640+
const actual = { ...defaultTasks, PICKLIST_SYNC_TASK_INTERVAL: '60' };
641+
expect(collectNonDefaultTaskIntervals(actual, defaultTasks)).to.deep.equal([
642+
{ key: 'PICKLIST_SYNC_TASK_INTERVAL', default: 120, actual: '60' },
643+
]);
644+
});
628645
});

0 commit comments

Comments
 (0)