Files
openclaw/src/config/logging-max-file-bytes.test.ts
T
tanshanshan 8a8f9dc8cb fix(config): append numeric bound hints to ceiling/floor validation errors (#84852)
* fix(config): append numeric bound hints to ceiling/floor validation errors

When a config value exceeds a schema-enforced ceiling or falls below a
floor, the error message now includes the constraint explicitly:
  - Inclusive: `(maximum: 20)` / `(minimum: 0)`
  - Exclusive: `(must be less than 5)` / `(must be greater than 0)`

This matches the clarity that enum/union rejections already get via
`(allowed: …)` hints, and avoids the misleading "minimum: 0" wording
that previous attempts produced for `.positive()` / `.gt(0)` rejections.

Only numeric-origin `too_big`/`too_small` issues are enriched; string,
array, and file-size origins are left unchanged.

Fixes #52500

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test(config): update maxFileBytes test for numeric bound hint

The test snapshot for `logging.maxFileBytes: 0` rejection now includes
the `(must be greater than 0)` hint appended by the numeric bound
enrichment added in the previous commit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(config): guard nullable record in appendNumericBoundHint call

ClawSweeper P1: `record` from `toIssueRecord()` can be null, but
`appendNumericBoundHint` expects a non-null `UnknownIssueRecord`.
Guard with a ternary so the original message is returned when record
is null (which only happens for malformed/empty issues that already
produce generic "Invalid input" messages).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: tanshanshan <tanshanshan@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 17:44:29 +08:00

31 lines
743 B
TypeScript

import { describe, expect, it } from "vitest";
import { validateConfigObject } from "./validation.js";
describe("logging.maxFileBytes config", () => {
it("accepts a positive maxFileBytes", () => {
const res = validateConfigObject({
logging: {
maxFileBytes: 1024,
},
});
expect(res.ok).toBe(true);
});
it("rejects non-positive maxFileBytes", () => {
const res = validateConfigObject({
logging: {
maxFileBytes: 0,
},
});
expect(res.ok).toBe(false);
if (!res.ok) {
expect(res.issues).toEqual([
{
path: "logging.maxFileBytes",
message: "Too small: expected number to be >0 (must be greater than 0)",
},
]);
}
});
});