mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 17:34:45 +00:00
fix(tlon): wrap malformed scry json
This commit is contained in:
@@ -97,6 +97,7 @@ Docs: https://docs.openclaw.ai
|
||||
- Signal: return a stable installer error when GitHub release metadata is malformed JSON.
|
||||
- ClawHub: report malformed successful marketplace JSON responses with owned errors instead of leaking raw parser failures.
|
||||
- Provider usage: report malformed successful usage JSON responses with stable provider errors instead of leaking raw parser failures.
|
||||
- Tlon/Urbit: report malformed scry response JSON with owned errors instead of leaking raw parser failures.
|
||||
- Matrix: ignore malformed percent-encoding in optional location URI parameters instead of letting a bad `geo:` event abort inbound message handling.
|
||||
- Web search: auto-detect Brave through its legacy `tools.web.search.apiKey` compatibility fallback while keeping doctor migration to `plugins.entries.brave.config.webSearch.apiKey` as the canonical repair, so allowlisted isolated cron runs do not report `web_search` unavailable before migration. Fixes #81538. Thanks @atomicmonk.
|
||||
- Plugins: memoize repeated in-process plugin metadata snapshots and keep vanished managed-install residue from forcing full derived discovery, reducing gateway/status startup scans under large plugin sets. Fixes #81143 and #79806. (#81570) Thanks @Kaspre, @holgergruenhagen, @JanPlessow, and @mjamiv.
|
||||
|
||||
36
extensions/tlon/src/urbit/channel-ops.test.ts
Normal file
36
extensions/tlon/src/urbit/channel-ops.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { scryUrbitPath } from "./channel-ops.js";
|
||||
import { urbitFetch } from "./fetch.js";
|
||||
|
||||
vi.mock("./fetch.js", () => ({
|
||||
urbitFetch: vi.fn(),
|
||||
}));
|
||||
|
||||
describe("Urbit channel operations", () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(urbitFetch).mockReset();
|
||||
});
|
||||
|
||||
it("wraps malformed scry response JSON", async () => {
|
||||
const release = vi.fn().mockResolvedValue(undefined);
|
||||
vi.mocked(urbitFetch).mockResolvedValue({
|
||||
response: new Response("{not json", {
|
||||
status: 200,
|
||||
headers: { "content-type": "application/json" },
|
||||
}),
|
||||
finalUrl: "https://example.com/~/scry/chat/inbox.json",
|
||||
release,
|
||||
});
|
||||
|
||||
await expect(
|
||||
scryUrbitPath(
|
||||
{
|
||||
baseUrl: "https://example.com",
|
||||
cookie: "urbauth-~zod=123",
|
||||
},
|
||||
{ path: "/chat/inbox.json", auditContext: "test" },
|
||||
),
|
||||
).rejects.toThrow("Urbit scry response was malformed JSON for path /chat/inbox.json");
|
||||
expect(release).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@@ -88,7 +88,11 @@ export async function scryUrbitPath(
|
||||
if (!response.ok) {
|
||||
throw new Error(`Scry failed: ${response.status} for path ${params.path}`);
|
||||
}
|
||||
return await response.json();
|
||||
try {
|
||||
return await response.json();
|
||||
} catch (cause) {
|
||||
throw new Error(`Urbit scry response was malformed JSON for path ${params.path}`, { cause });
|
||||
}
|
||||
} finally {
|
||||
await release();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user