mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
fix(doctor): preserve Unicode in migration reports (#104851)
This commit is contained in:
@@ -946,11 +946,11 @@ function renderFailureMarkdown(payload: {
|
||||
}
|
||||
|
||||
function sanitizeFailureReportText(value: string): string {
|
||||
return value
|
||||
const sanitized = value
|
||||
.replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g, "[redacted-email]")
|
||||
.replace(/(api[_-]?key|token|secret|password)[=-][A-Za-z0-9._-]+/gi, "$1-[redacted]")
|
||||
.replace(/(api[_-]?key|token|secret|password)=\S+/gi, "$1=[redacted]")
|
||||
.slice(0, 500);
|
||||
.replace(/(api[_-]?key|token|secret|password)=\S+/gi, "$1=[redacted]");
|
||||
return truncateUtf16Safe(sanitized, 500);
|
||||
}
|
||||
|
||||
function shortenFailureReportPath(filePath: string): string {
|
||||
|
||||
@@ -1566,6 +1566,8 @@ describe("runDoctorSessionSqlite", () => {
|
||||
it("keeps truncated GitHub issue bodies on a valid UTF-16 boundary", () => {
|
||||
const store = createLegacyStore();
|
||||
const manifestPath = path.join(store.tempDir, "failed-migration.json");
|
||||
const unpairedSurrogate =
|
||||
/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u;
|
||||
const writeManifest = (messages: string[], targetCount = 1) => {
|
||||
const manifest: SessionSqliteMigrationManifest = {
|
||||
failedAt: "2030-01-01T00:00:00.000Z",
|
||||
@@ -1592,6 +1594,11 @@ describe("runDoctorSessionSqlite", () => {
|
||||
fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, { mode: 0o600 });
|
||||
};
|
||||
|
||||
writeManifest([`${"x".repeat(499)}🎉tail`]);
|
||||
const fieldIssue = createSessionSqliteMigrationFailureIssue(manifestPath);
|
||||
expect(fieldIssue?.body).not.toMatch(unpairedSurrogate);
|
||||
expect(new URL(fieldIssue?.url ?? "").searchParams.get("body")).not.toContain("�");
|
||||
|
||||
const baseMessages = Array.from({ length: 9 }, () => "x".repeat(500));
|
||||
writeManifest([...baseMessages, "MESSAGE_START"]);
|
||||
const probe = createSessionSqliteMigrationFailureIssue(manifestPath);
|
||||
@@ -1622,9 +1629,7 @@ describe("runDoctorSessionSqlite", () => {
|
||||
|
||||
writeManifest([`${"x".repeat(19_999 - bodyMessageOffset)}🎉tail`], bodyTargetCount);
|
||||
const bodyIssue = createSessionSqliteMigrationFailureIssue(manifestPath);
|
||||
expect(bodyIssue?.body).not.toMatch(
|
||||
/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u,
|
||||
);
|
||||
expect(bodyIssue?.body).not.toMatch(unpairedSurrogate);
|
||||
});
|
||||
|
||||
it("recovers only manifests matching an explicit store selector", async () => {
|
||||
|
||||
Reference in New Issue
Block a user