惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
美团技术团队
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题
博客园_首页
雷峰网
雷峰网
V
V2EX
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)
量子位
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
V
Visual Studio Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Jina AI
Jina AI
月光博客
月光博客
L
LangChain Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test: guard memory host post json calls · openclaw/opencl...
steipete · 2026-05-12 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -11,6 +11,28 @@ type RetryOptions = {

1111

shouldRetry: (err: unknown) => boolean;

1212

};

1313
14+

type PostJsonParams = {

15+

url?: unknown;

16+

headers?: unknown;

17+

body?: unknown;

18+

errorPrefix?: unknown;

19+

attachStatus?: unknown;

20+

};

21+
22+

function requirePostJsonParams(

23+

postJsonMock: ReturnType<typeof vi.mocked<typeof import("./post-json.js").postJson>>,

24+

): PostJsonParams {

25+

const [call] = postJsonMock.mock.calls;

26+

if (!call) {

27+

throw new Error("expected postJson call");

28+

}

29+

const [params] = call;

30+

if (typeof params !== "object" || params === null || Array.isArray(params)) {

31+

throw new Error("expected postJson params to be an object");

32+

}

33+

return params;

34+

}

35+
1436

function requireRetryOptions(call: unknown[] | undefined): RetryOptions {

1537

const options = call?.[1] as RetryOptions | undefined;

1638

if (!options) {

@@ -49,12 +71,12 @@ describe("postJsonWithRetry", () => {

4971

});

5072
5173

expect(result).toEqual({ ok: true, ids: [1, 2] });

52-

const postJsonParams = postJsonMock.mock.calls[0]?.[0];

53-

expect(postJsonParams?.url).toBe("https://memory.example/v1/batch");

54-

expect(postJsonParams?.headers).toEqual({ Authorization: "Bearer test" });

55-

expect(postJsonParams?.body).toEqual({ chunks: ["a", "b"] });

56-

expect(postJsonParams?.errorPrefix).toBe("memory batch failed");

57-

expect(postJsonParams?.attachStatus).toBe(true);

74+

const postJsonParams = requirePostJsonParams(postJsonMock);

75+

expect(postJsonParams.url).toBe("https://memory.example/v1/batch");

76+

expect(postJsonParams.headers).toEqual({ Authorization: "Bearer test" });

77+

expect(postJsonParams.body).toEqual({ chunks: ["a", "b"] });

78+

expect(postJsonParams.errorPrefix).toBe("memory batch failed");

79+

expect(postJsonParams.attachStatus).toBe(true);

5880
5981

const retryOptions = requireRetryOptions(retryAsyncMock.mock.calls[0]);

6082

expect(retryOptions.attempts).toBe(3);

Original file line numberDiff line numberDiff line change

@@ -7,6 +7,23 @@ vi.mock("./post-json.js", () => ({

77

postJson: postJsonMock,

88

}));

99
10+

function requirePostJsonParams(): {

11+

url?: unknown;

12+

headers?: unknown;

13+

body?: unknown;

14+

errorPrefix?: unknown;

15+

} {

16+

const [call] = postJsonMock.mock.calls;

17+

if (!call) {

18+

throw new Error("expected postJson call");

19+

}

20+

const [params] = call;

21+

if (typeof params !== "object" || params === null || Array.isArray(params)) {

22+

throw new Error("expected postJson params to be an object");

23+

}

24+

return params;

25+

}

26+
1027

describe("fetchRemoteEmbeddingVectors", () => {

1128

beforeEach(() => {

1229

postJsonMock.mockReset();

@@ -27,11 +44,11 @@ describe("fetchRemoteEmbeddingVectors", () => {

2744

});

2845
2946

expect(vectors).toEqual([[0.1, 0.2], [], [0.3]]);

30-

const postJsonParams = postJsonMock.mock.calls[0]?.[0];

31-

expect(postJsonParams?.url).toBe("https://memory.example/v1/embeddings");

32-

expect(postJsonParams?.headers).toEqual({ Authorization: "Bearer test" });

33-

expect(postJsonParams?.body).toEqual({ input: ["one", "two", "three"] });

34-

expect(postJsonParams?.errorPrefix).toBe("embedding fetch failed");

47+

const postJsonParams = requirePostJsonParams();

48+

expect(postJsonParams.url).toBe("https://memory.example/v1/embeddings");

49+

expect(postJsonParams.headers).toEqual({ Authorization: "Bearer test" });

50+

expect(postJsonParams.body).toEqual({ input: ["one", "two", "three"] });

51+

expect(postJsonParams.errorPrefix).toBe("embedding fetch failed");

3552

});

3653
3754

it("throws a status-rich error on non-ok responses", async () => {