Repository navigation
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3b97c97a8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| @@ -139,7 +139,8 @@ export function validateCronForm(form: CronFormState): CronFieldErrors { | |||
| const timeoutRaw = form.timeoutSeconds.trim(); | |||
| if (timeoutRaw) { | |||
| const timeout = toNumber(timeoutRaw, 0); | |||
| if (timeout <= 0) { | |||
| // 0 = no timeout (valid), negative = invalid | |||
| if (timeout < 0) { | |||
There was a problem hiding this comment.
Reject non-numeric timeout values in cron form
Using timeout < 0 here makes malformed values pass validation because toNumber maps NaN to 0 (ui/src/ui/format.ts). With this change, inputs like "abc" no longer produce cron.errors.timeoutInvalid, and the new payload logic then serializes that non-empty invalid input as timeoutSeconds: 0 (no-timeout mode). Since the timeout field is plain text (ui/src/ui/views/cron.ts), this regression can occur in normal UI usage and silently changes job behavior.
Useful? React with 👍 / 👎.
Greptile SummaryThis PR fixes a legitimate UX bug where entering Key issues found:
Confidence Score: 2/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: ui/src/ui/controllers/cron.ts
Line: 141-145
Comment:
**Non-numeric strings now silently pass validation**
Changing `<= 0` to `< 0` introduced a regression for non-numeric input. `toNumber` returns its fallback (`0`) for any non-parseable string, so `toNumber("abc", 0)` → `0`. Previously `0 <= 0` was `true`, so garbage input triggered a validation error. Now `0 < 0` is `false`, meaning strings like `"abc"` or `"foo"` silently pass validation.
This then flows into `buildCronPayload` where the same `toNumber("abc", 0)` call returns `0`, `0 === 0 && "abc" !== ""` is `true`, and `payload.timeoutSeconds = 0` is incorrectly emitted as if the user had explicitly opted into "no timeout" mode.
The fix is to use a fallback that would still fail the `< 0` check when the raw string is not a valid number, or to add an explicit `isFinite` guard:
```suggestion
const timeout = toNumber(timeoutRaw, -1);
// -1 fallback: non-numeric strings → -1 → caught by timeout < 0
// 0 = no timeout (valid), negative = invalid
if (timeout < 0) {
errors.timeoutSeconds = "cron.errors.timeoutInvalid";
}
```
Alternatively:
```ts
const timeout = toNumber(timeoutRaw, NaN);
if (!Number.isFinite(timeout) || timeout < 0) {
errors.timeoutSeconds = "cron.errors.timeoutInvalid";
}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: ui/src/ui/controllers/cron.ts
Line: 582-583
Comment:
**Payload builder also affected by non-numeric strings**
Even after fixing validation, the `buildCronPayload` path has the same implicit assumption: `toNumber(form.timeoutSeconds, 0)` returns `0` for any non-numeric input, and the condition `timeoutSeconds === 0 && form.timeoutSeconds.trim() !== ""` is `true` for strings like `"abc"`. If validation is hardened (as suggested above), this path will not be reached in the normal flow, but for robustness consider an explicit numeric-validity check here too:
```suggestion
} else if (timeoutSeconds === 0 && form.timeoutSeconds.trim() !== "" && Number.isFinite(Number(form.timeoutSeconds.trim()))) {
payload.timeoutSeconds = 0;
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: ui/src/ui/controllers/cron.test.ts
Line: 852-868
Comment:
**Test doesn't cover non-numeric input regression**
The new test only checks `"-5"` (rejected) and `"0"` (accepted), but misses the case where a non-numeric string like `"abc"` is entered. After the change from `<= 0` to `< 0`, non-numeric strings silently pass validation (see comment on `cron.ts:141`). A test for this case would catch the regression:
```ts
const errorsNonNumeric = validateCronForm({
...DEFAULT_CRON_FORM,
payloadKind: "agentTurn",
payloadText: "run",
timeoutSeconds: "abc",
});
expect(errorsNonNumeric.timeoutSeconds).toBe("cron.errors.timeoutInvalid");
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: b3b97c9 |
| const timeout = toNumber(timeoutRaw, 0); | ||
| if (timeout <= 0) { | ||
| // 0 = no timeout (valid), negative = invalid | ||
| if (timeout < 0) { | ||
| errors.timeoutSeconds = "cron.errors.timeoutInvalid"; | ||
| } |
There was a problem hiding this comment.
Non-numeric strings now silently pass validation
Changing <= 0 to < 0 introduced a regression for non-numeric input. toNumber returns its fallback (0) for any non-parseable string, so toNumber("abc", 0) → 0. Previously 0 <= 0 was true, so garbage input triggered a validation error. Now 0 < 0 is false, meaning strings like "abc" or "foo" silently pass validation.
This then flows into buildCronPayload where the same toNumber("abc", 0) call returns 0, 0 === 0 && "abc" !== "" is true, and payload.timeoutSeconds = 0 is incorrectly emitted as if the user had explicitly opted into "no timeout" mode.
The fix is to use a fallback that would still fail the < 0 check when the raw string is not a valid number, or to add an explicit isFinite guard:
| const timeout = toNumber(timeoutRaw, 0); | |
| if (timeout <= 0) { | |
| // 0 = no timeout (valid), negative = invalid | |
| if (timeout < 0) { | |
| errors.timeoutSeconds = "cron.errors.timeoutInvalid"; | |
| } | |
| const timeout = toNumber(timeoutRaw, -1); | |
| // -1 fallback: non-numeric strings → -1 → caught by timeout < 0 | |
| // 0 = no timeout (valid), negative = invalid | |
| if (timeout < 0) { | |
| errors.timeoutSeconds = "cron.errors.timeoutInvalid"; | |
| } |
Alternatively:
const timeout = toNumber(timeoutRaw, NaN);
if (!Number.isFinite(timeout) || timeout < 0) {
errors.timeoutSeconds = "cron.errors.timeoutInvalid";
}Prompt To Fix With AI
This is a comment left during a code review.
Path: ui/src/ui/controllers/cron.ts
Line: 141-145
Comment:
**Non-numeric strings now silently pass validation**
Changing `<= 0` to `< 0` introduced a regression for non-numeric input. `toNumber` returns its fallback (`0`) for any non-parseable string, so `toNumber("abc", 0)` → `0`. Previously `0 <= 0` was `true`, so garbage input triggered a validation error. Now `0 < 0` is `false`, meaning strings like `"abc"` or `"foo"` silently pass validation.
This then flows into `buildCronPayload` where the same `toNumber("abc", 0)` call returns `0`, `0 === 0 && "abc" !== ""` is `true`, and `payload.timeoutSeconds = 0` is incorrectly emitted as if the user had explicitly opted into "no timeout" mode.
The fix is to use a fallback that would still fail the `< 0` check when the raw string is not a valid number, or to add an explicit `isFinite` guard:
```suggestion
const timeout = toNumber(timeoutRaw, -1);
// -1 fallback: non-numeric strings → -1 → caught by timeout < 0
// 0 = no timeout (valid), negative = invalid
if (timeout < 0) {
errors.timeoutSeconds = "cron.errors.timeoutInvalid";
}
```
Alternatively:
```ts
const timeout = toNumber(timeoutRaw, NaN);
if (!Number.isFinite(timeout) || timeout < 0) {
errors.timeoutSeconds = "cron.errors.timeoutInvalid";
}
```
How can I resolve this? If you propose a fix, please make it concise.| } else if (timeoutSeconds === 0 && form.timeoutSeconds.trim() !== "") { | ||
| payload.timeoutSeconds = 0; |
There was a problem hiding this comment.
Payload builder also affected by non-numeric strings
Even after fixing validation, the buildCronPayload path has the same implicit assumption: toNumber(form.timeoutSeconds, 0) returns 0 for any non-numeric input, and the condition timeoutSeconds === 0 && form.timeoutSeconds.trim() !== "" is true for strings like "abc". If validation is hardened (as suggested above), this path will not be reached in the normal flow, but for robustness consider an explicit numeric-validity check here too:
| } else if (timeoutSeconds === 0 && form.timeoutSeconds.trim() !== "") { | |
| payload.timeoutSeconds = 0; | |
| } else if (timeoutSeconds === 0 && form.timeoutSeconds.trim() !== "" && Number.isFinite(Number(form.timeoutSeconds.trim()))) { | |
| payload.timeoutSeconds = 0; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: ui/src/ui/controllers/cron.ts
Line: 582-583
Comment:
**Payload builder also affected by non-numeric strings**
Even after fixing validation, the `buildCronPayload` path has the same implicit assumption: `toNumber(form.timeoutSeconds, 0)` returns `0` for any non-numeric input, and the condition `timeoutSeconds === 0 && form.timeoutSeconds.trim() !== ""` is `true` for strings like `"abc"`. If validation is hardened (as suggested above), this path will not be reached in the normal flow, but for robustness consider an explicit numeric-validity check here too:
```suggestion
} else if (timeoutSeconds === 0 && form.timeoutSeconds.trim() !== "" && Number.isFinite(Number(form.timeoutSeconds.trim()))) {
payload.timeoutSeconds = 0;
```
How can I resolve this? If you propose a fix, please make it concise.| it("rejects negative timeoutSeconds but allows zero (no-timeout mode)", () => { | ||
| const errorsNeg = validateCronForm({ | ||
| ...DEFAULT_CRON_FORM, | ||
| payloadKind: "agentTurn", | ||
| payloadText: "run", | ||
| timeoutSeconds: "-5", | ||
| }); | ||
| expect(errorsNeg.timeoutSeconds).toBe("cron.errors.timeoutInvalid"); | ||
|
|
||
| const errorsZero = validateCronForm({ | ||
| ...DEFAULT_CRON_FORM, | ||
| payloadKind: "agentTurn", | ||
| payloadText: "run", | ||
| timeoutSeconds: "0", | ||
| }); | ||
| expect(errorsZero.timeoutSeconds).toBeUndefined(); | ||
| }); |
There was a problem hiding this comment.
Test doesn't cover non-numeric input regression
The new test only checks "-5" (rejected) and "0" (accepted), but misses the case where a non-numeric string like "abc" is entered. After the change from <= 0 to < 0, non-numeric strings silently pass validation (see comment on cron.ts:141). A test for this case would catch the regression:
const errorsNonNumeric = validateCronForm({
...DEFAULT_CRON_FORM,
payloadKind: "agentTurn",
payloadText: "run",
timeoutSeconds: "abc",
});
expect(errorsNonNumeric.timeoutSeconds).toBe("cron.errors.timeoutInvalid");Prompt To Fix With AI
This is a comment left during a code review.
Path: ui/src/ui/controllers/cron.test.ts
Line: 852-868
Comment:
**Test doesn't cover non-numeric input regression**
The new test only checks `"-5"` (rejected) and `"0"` (accepted), but misses the case where a non-numeric string like `"abc"` is entered. After the change from `<= 0` to `< 0`, non-numeric strings silently pass validation (see comment on `cron.ts:141`). A test for this case would catch the regression:
```ts
const errorsNonNumeric = validateCronForm({
...DEFAULT_CRON_FORM,
payloadKind: "agentTurn",
payloadText: "run",
timeoutSeconds: "abc",
});
expect(errorsNonNumeric.timeoutSeconds).toBe("cron.errors.timeoutInvalid");
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6866fc68a1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const timeout = toNumber(timeoutRaw, 0); | ||
| if (timeout <= 0) { | ||
| // 0 = no timeout (valid), negative = invalid | ||
| if (timeout < 0) { |
There was a problem hiding this comment.
Reject non-numeric timeout values in cron form
Fresh evidence in this commit: validateCronForm now only rejects values < 0, but it parses with toNumber(timeoutRaw, 0), so non-numeric input like "abc" becomes 0 and passes validation; then buildCronPayload's new timeoutSeconds === 0 && trim() !== "" branch serializes that invalid input as timeoutSeconds: 0 (no-timeout mode). This means a malformed timeout entered in the text field silently changes job behavior instead of surfacing cron.errors.timeoutInvalid.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c857701d2b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| payload.timeoutSeconds = timeoutSeconds; | ||
| const timeoutRaw = form.timeoutSeconds.trim(); | ||
| const timeoutSeconds = toNumber(timeoutRaw, 0); | ||
| if (!isNaN(Number(timeoutRaw)) && timeoutRaw !== "") { |
There was a problem hiding this comment.
Reject non-finite timeout values in cron form
Fresh evidence in this commit: the new guard !isNaN(Number(timeoutRaw)) treats non-finite inputs like "Infinity" or "1e309" as valid numbers, while toNumber(timeoutRaw, 0) collapses them to 0. That means malformed timeout text can pass validation and then be serialized as timeoutSeconds: 0 (no-timeout mode) instead of raising cron.errors.timeoutInvalid, which silently changes cron job behavior from user-entered free-text input.
Useful? React with 👍 / 👎.
…nclaw#41272) Change validation from `timeout <= 0` to `timeout < 0` so that 0 is accepted as a valid value meaning "no timeout". Also update the payload builder to include `timeoutSeconds: 0` when explicitly set by the user. Co-authored-by: Copilot <[email protected]>
|
Closing to manage active PR count. Will reopen when slot is available. |
Summary
timeoutSeconds: 0, which should represent "no timeout" mode for long-running jobs.ui/src/ui/controllers/cron.ts: Changed validation fromtimeout <= 0totimeout < 0so zero is accepted. UpdatedbuildCronPayload()to includetimeoutSeconds: 0in payload when explicitly set.ui/src/ui/controllers/cron.test.ts: Updated existing test expectation and added new test verifying negative values are rejected while zero is allowed.Change Type
Scope
Linked Issue/PR
Security Impact
Repro + Verification
cron.errors.timeoutInvalidtimeoutSeconds: 0in payloadEvidence
Human Verification
Compatibility / Migration