Skip to content

Commit 49e2888

Browse files
committed
fix(cli): wrap malformed trajectory export requests
1 parent a1de61b commit 49e2888

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Docs: https://docs.openclaw.ai
4848
- QQBot: reject malformed stored cron payload base64 before JSON decoding structured reminder data.
4949
- Telnyx voice-call: use the raw `client_state` fallback when webhook state is malformed base64 instead of using silently corrupted decoded text.
5050
- Google Meet: report malformed node-host params JSON with plugin-owned errors instead of leaking raw JSON parser failures.
51+
- CLI/export-trajectory: report malformed encoded request JSON with a stable CLI error instead of leaking raw parser output.
5152
- Models config/auth: stop inferring provider env-var markers from broad `^[A-Z_][A-Z0-9_]*$` strings, and resolve config-backed provider `apiKey` values only through structured env SecretRefs (`secrets.providers[id]` / `secrets.defaults`), so unrelated env vars cannot accidentally become provider credentials. Thanks @sallyom.
5253
- Media fetch: skip allocating and buffering the response body for bodyless media responses (HEAD probes and 204-style empty bodies), avoiding wasted heap on streams that carry no payload. Thanks @shakkernerd.
5354
- CLI/onboarding: forward provider-specific auth flags (e.g. `--openai-api-key`) through the onboarding wizard so they reach provider auth methods via `ctx.opts`, letting `--openai-api-key "$OPENAI_API_KEY"` skip the redundant "use existing env var?" prompt in non-interactive harnesses. (#81669) Thanks @sjf.

src/commands/export-trajectory.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ describe("exportTrajectoryCommand", () => {
4545
expect(runtime.exit).toHaveBeenCalledWith(1);
4646
});
4747

48+
it("reports malformed encoded request JSON without leaking parser output", async () => {
49+
const runtime = createRuntime();
50+
const requestJsonBase64 = Buffer.from("not json", "utf8").toString("base64url");
51+
52+
await exportTrajectoryCommand({ requestJsonBase64 }, runtime);
53+
54+
expect(runtime.error).toHaveBeenCalledWith(
55+
"Failed to decode trajectory export request: Encoded trajectory export request is invalid JSON",
56+
);
57+
expect(runtime.exit).toHaveBeenCalledWith(1);
58+
});
59+
4860
it("points missing session users at the sessions command", async () => {
4961
const runtime = createRuntime();
5062

src/commands/export-trajectory.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ function decodeExportTrajectoryRequest(encoded: string): Partial<ExportTrajector
4646
if (!ENCODED_EXPORT_REQUEST_RE.test(trimmed)) {
4747
throw new Error("Encoded trajectory export request is invalid");
4848
}
49-
const decoded = JSON.parse(Buffer.from(trimmed, "base64url").toString("utf8")) as unknown;
49+
let decoded: unknown;
50+
try {
51+
decoded = JSON.parse(Buffer.from(trimmed, "base64url").toString("utf8")) as unknown;
52+
} catch {
53+
throw new Error("Encoded trajectory export request is invalid JSON");
54+
}
5055
if (!decoded || typeof decoded !== "object" || Array.isArray(decoded)) {
5156
throw new Error("Encoded trajectory export request must be a JSON object");
5257
}

0 commit comments

Comments
 (0)