fix(config): append bound hints to numeric ceiling/floor rejections#62091
fix(config): append bound hints to numeric ceiling/floor rejections#62091martingarramon wants to merge 1 commit into
Conversation
Greptile SummaryAdds a Confidence Score: 5/5Safe to merge; the new code path is scoped to too_big/too_small Zod codes only and does not affect other validation paths. All findings are P2 style suggestions. The exclusive-bound hint redundancy is unlikely to surface in practice since most numeric config constraints use inclusive bounds, and it does not affect correctness. src/config/validation.ts lines 353–360 (exclusive bound hint wording) Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/config/validation.ts
Line: 353-360
Comment:
**Exclusive bound hint duplicates the base Zod message**
For exclusive constraints (`inclusive: false`), the appended hint is identical to what Zod already emits. A `too_big` exclusive will produce `"Number must be less than 5 (must be less than 5)"` and a `too_small` exclusive will produce `"Number must be greater than 0 (must be greater than 0)"`. A compact label like `(exclusive maximum: N)` / `(exclusive minimum: N)` adds the same structured context without repeating the prose.
```suggestion
return record.inclusive !== false
? `(maximum: ${record.maximum})`
: `(exclusive maximum: ${record.maximum})`;
}
if (code === "too_small" && typeof record.minimum === "number") {
return record.inclusive !== false
? `(minimum: ${record.minimum})`
: `(exclusive minimum: ${record.minimum})`;
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(config): append structured bound hin..." | Re-trigger Greptile |
| return record.inclusive !== false | ||
| ? `(maximum: ${record.maximum})` | ||
| : `(must be less than ${record.maximum})`; | ||
| } | ||
| if (code === "too_small" && typeof record.minimum === "number") { | ||
| return record.inclusive !== false | ||
| ? `(minimum: ${record.minimum})` | ||
| : `(must be greater than ${record.minimum})`; |
There was a problem hiding this comment.
Exclusive bound hint duplicates the base Zod message
For exclusive constraints (inclusive: false), the appended hint is identical to what Zod already emits. A too_big exclusive will produce "Number must be less than 5 (must be less than 5)" and a too_small exclusive will produce "Number must be greater than 0 (must be greater than 0)". A compact label like (exclusive maximum: N) / (exclusive minimum: N) adds the same structured context without repeating the prose.
| return record.inclusive !== false | |
| ? `(maximum: ${record.maximum})` | |
| : `(must be less than ${record.maximum})`; | |
| } | |
| if (code === "too_small" && typeof record.minimum === "number") { | |
| return record.inclusive !== false | |
| ? `(minimum: ${record.minimum})` | |
| : `(must be greater than ${record.minimum})`; | |
| return record.inclusive !== false | |
| ? `(maximum: ${record.maximum})` | |
| : `(exclusive maximum: ${record.maximum})`; | |
| } | |
| if (code === "too_small" && typeof record.minimum === "number") { | |
| return record.inclusive !== false | |
| ? `(minimum: ${record.minimum})` | |
| : `(exclusive minimum: ${record.minimum})`; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/config/validation.ts
Line: 353-360
Comment:
**Exclusive bound hint duplicates the base Zod message**
For exclusive constraints (`inclusive: false`), the appended hint is identical to what Zod already emits. A `too_big` exclusive will produce `"Number must be less than 5 (must be less than 5)"` and a `too_small` exclusive will produce `"Number must be greater than 0 (must be greater than 0)"`. A compact label like `(exclusive maximum: N)` / `(exclusive minimum: N)` adds the same structured context without repeating the prose.
```suggestion
return record.inclusive !== false
? `(maximum: ${record.maximum})`
: `(exclusive maximum: ${record.maximum})`;
}
if (code === "too_small" && typeof record.minimum === "number") {
return record.inclusive !== false
? `(minimum: ${record.minimum})`
: `(exclusive minimum: ${record.minimum})`;
```
How can I resolve this? If you propose a fix, please make it concise.cae2c39 to
3976f47
Compare
…ejections Closes openclaw#52500 When a config value exceeds a `.max()` or `.min()` Zod constraint, the validation formatter now appends a structured `(maximum: N)` or `(minimum: N)` hint — matching the existing `(allowed: ...)` pattern used for enum rejections. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3976f47 to
4f0077d
Compare
|
Closing this to free queue capacity — happy to reopen if there's interest. The fix still applies on current main if someone wants to pick it up. |
Closes #52500
When a numeric config value violates a
.max()or.min()Zod constraint, the error message now appends a structured(maximum: N)or(minimum: N)hint — matching the existing(allowed: ...)pattern already used for enum rejections.Before:
session.agentToAgent.maxPingPongTurns: Number must be less than or equal to 5After:
session.agentToAgent.maxPingPongTurns: Number must be less than or equal to 5 (maximum: 5)The
formatBoundHinthelper handles both inclusive (maximum: N) and exclusive (must be less than N) constraints, and is scoped totoo_big/too_smallZod issue codes only — it does not affect enum, union, or type-mismatch error paths.Testing: Two new test cases in
validation.allowed-values.test.tscovering ceiling and floor violations againstsession.agentToAgent.maxPingPongTurns(capped at 0–5). Pre-commit hook skipped due to pre-existingtsgotype errors on main (#62014).🤖 Generated with Claude Code