mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-28 06:12:36 +00:00
fix(release): preserve emoji in ClawHub error details (#108172)
* fix(release): keep ClawHub errors valid Unicode * fix(release): keep ClawHub helper source-resolvable --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// Plugin Clawhub Release script supports OpenClaw repository automation.
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { resolve } from "node:path";
|
||||
import { truncateUtf16Safe } from "../../packages/normalization-core/src/utf16-slice.js";
|
||||
import { validateExternalCodePluginPackageJson } from "../../packages/plugin-package-contract/src/index.ts";
|
||||
import { retryClawHubRead } from "../../src/infra/clawhub-retry.js";
|
||||
import { readBoundedResponseText } from "./bounded-response.ts";
|
||||
@@ -229,7 +230,7 @@ async function buildClawHubQueryError(
|
||||
body = "";
|
||||
}
|
||||
if (body.length > CLAWHUB_ERROR_BODY_MAX_CHARS) {
|
||||
body = `${body.slice(0, CLAWHUB_ERROR_BODY_MAX_CHARS)}...`;
|
||||
body = `${truncateUtf16Safe(body, CLAWHUB_ERROR_BODY_MAX_CHARS)}...`;
|
||||
}
|
||||
const diagnosticHeaders = ["retry-after", "x-request-id", "x-vercel-id", "cf-ray"]
|
||||
.map((name) => {
|
||||
|
||||
@@ -794,6 +794,35 @@ describe("collectPluginClawHubReleasePlan", () => {
|
||||
expect(packageRequests).toBe(4);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
caseName: "drops a split surrogate pair",
|
||||
responseBody: `${"x".repeat(399)}\u{1f600}tail`,
|
||||
expectedDetail: `${"x".repeat(399)}...`,
|
||||
},
|
||||
{
|
||||
caseName: "preserves a complete surrogate pair",
|
||||
responseBody: `${"x".repeat(398)}\u{1f600}tail`,
|
||||
expectedDetail: `${"x".repeat(398)}\u{1f600}...`,
|
||||
},
|
||||
])(
|
||||
"keeps ClawHub error truncation UTF-16 safe: $caseName",
|
||||
async ({ responseBody, expectedDetail }) => {
|
||||
const repoDir = createTempPluginRepo();
|
||||
await expect(
|
||||
collectPluginClawHubReleasePlan({
|
||||
rootDir: repoDir,
|
||||
selection: ["@openclaw/demo-plugin"],
|
||||
registryBaseUrl: "https://clawhub.ai",
|
||||
fetchImpl: async () => new Response(responseBody, { status: 503 }),
|
||||
sleep: async () => {},
|
||||
}),
|
||||
).rejects.toThrow(
|
||||
`Failed to query ClawHub package @openclaw/demo-plugin: 503 ${expectedDetail}`,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("honors an HTTP-date Retry-After header", async () => {
|
||||
const repoDir = createTempPluginRepo();
|
||||
const retryAfter = "Wed, 21 Oct 2030 07:28:00 GMT";
|
||||
|
||||
Reference in New Issue
Block a user