-
Notifications
You must be signed in to change notification settings - Fork 93
fix(config): dual-emit for heartbeat null-mismatch and equal-values #25731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,15 +43,23 @@ export const HeartbeatConfigSchema = z | |
| const startNull = config.activeHoursStart == null; | ||
| const endNull = config.activeHoursEnd == null; | ||
| if (startNull !== endNull) { | ||
| // Emit on the null side only. Heartbeat's defaults are 8/22, so | ||
| // delete-and-retry strips the null key, letting the non-null default | ||
| // restore it while preserving the user's explicit value on the other | ||
| // side. | ||
| // Emit on both fields so validateWithSchema's delete-and-retry strips | ||
| // both sides in one pass. Single-emit on the null side can cascade when | ||
| // the explicit value happens to equal the opposite default (e.g. | ||
| // { start: null, end: 8 } β strip start β default 8 β equal check fires | ||
| // β loader falls back to full defaults, wiping unrelated keys like | ||
| // maxTokens). | ||
| const message = | ||
| "heartbeat.activeHoursStart and heartbeat.activeHoursEnd must both be set or both be null"; | ||
| ctx.addIssue({ | ||
| code: z.ZodIssueCode.custom, | ||
| path: [startNull ? "activeHoursStart" : "activeHoursEnd"], | ||
| message: | ||
| "heartbeat.activeHoursStart and heartbeat.activeHoursEnd must both be set or both be null", | ||
| path: ["activeHoursStart"], | ||
| message, | ||
| }); | ||
| ctx.addIssue({ | ||
| code: z.ZodIssueCode.custom, | ||
| path: ["activeHoursEnd"], | ||
| message, | ||
| }); | ||
| return; | ||
| } | ||
|
|
@@ -60,11 +68,21 @@ export const HeartbeatConfigSchema = z | |
| config.activeHoursEnd != null && | ||
| config.activeHoursStart === config.activeHoursEnd | ||
| ) { | ||
| // Emit on both fields. Single-emit would strip one side and the default | ||
| // for that side could recreate a new mismatch (e.g. { start: 22, end: 22 } | ||
| // β strip end β default 22 β equal again), cascading to a full defaults | ||
| // reset that wipes unrelated fields. | ||
| const message = | ||
| "heartbeat.activeHoursStart and heartbeat.activeHoursEnd must not be equal (would create an empty window)"; | ||
| ctx.addIssue({ | ||
| code: z.ZodIssueCode.custom, | ||
| path: ["activeHoursStart"], | ||
| message, | ||
| }); | ||
| ctx.addIssue({ | ||
| code: z.ZodIssueCode.custom, | ||
| path: ["activeHoursEnd"], | ||
| message: | ||
| "heartbeat.activeHoursStart and heartbeat.activeHoursEnd must not be equal (would create an empty window)", | ||
| message, | ||
|
Comment on lines
82
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Emitting an additional issue on Useful? React with πΒ / π. |
||
| }); | ||
| } | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding an issue on
activeHoursEndhere causesvalidateWithSchemato delete both keys for any mixed-null input, so configs like{ activeHoursStart: null, activeHoursEnd: 20 }are rewritten to defaults(8, 22)instead of retaining the valid explicit20. This is a behavioral regression from the previous repair strategy and can silently widen heartbeat windows for users who only made one side null.Useful? React with πΒ / π.