mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
fix(doctor): keep scrubbed error truncation UTF-16 safe (#102066)
* fix(doctor): keep scrubbed error truncation UTF-16 safe * test(doctor): assert exact scrubbed error output --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
co-authored by
Peter Steinberger
parent
b62c796e51
commit
7daa090935
@@ -1,3 +1,5 @@
|
||||
import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice";
|
||||
|
||||
// Shared sanitization for doctor/lint/repair errors shown in terminal output.
|
||||
const ERR_MESSAGE_MAX_LEN = 256;
|
||||
|
||||
@@ -14,5 +16,5 @@ export function scrubDoctorErrorMessage(err: unknown): string {
|
||||
if (stripped.length <= ERR_MESSAGE_MAX_LEN) {
|
||||
return stripped;
|
||||
}
|
||||
return `${stripped.slice(0, ERR_MESSAGE_MAX_LEN - 3)}...`;
|
||||
return `${truncateUtf16Safe(stripped, ERR_MESSAGE_MAX_LEN - 3)}...`;
|
||||
}
|
||||
|
||||
@@ -135,6 +135,19 @@ describe("runDoctorLintChecks", () => {
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps truncated thrown error messages UTF-16 safe", async () => {
|
||||
const emoji = "\u{1F600}";
|
||||
const result = await runDoctorLintChecks(ctx, {
|
||||
checks: [
|
||||
check("emoji-boom", async () => {
|
||||
throw new Error(`${"A".repeat(252)}${emoji}${"B".repeat(10)}`);
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
expect(result.findings[0]?.message).toBe(`health check threw: ${"A".repeat(252)}...`);
|
||||
});
|
||||
});
|
||||
|
||||
describe("exitCodeFromFindings", () => {
|
||||
|
||||
Reference in New Issue
Block a user