Skip to content

Commit 14074d3

Browse files
committed
fix: restore repo-wide gate after upstream sync
1 parent 0ac9390 commit 14074d3

File tree

9 files changed

+143
-125
lines changed

9 files changed

+143
-125
lines changed

extensions/msteams/src/graph-upload.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ describe("resolveGraphChatId", () => {
111111
const result = await resolveGraphChatId({
112112
botFrameworkConversationId: "19:[email protected]",
113113
tokenProvider,
114-
fetchFn,
114+
fetchFn: withFetchPreconnect(fetchFn),
115115
});
116116
// Should short-circuit without making any API call
117117
expect(fetchFn).not.toHaveBeenCalled();
@@ -131,7 +131,7 @@ describe("resolveGraphChatId", () => {
131131
botFrameworkConversationId: "a:1abc_bot_framework_dm_id",
132132
userAadObjectId: "user-aad-object-id-123",
133133
tokenProvider,
134-
fetchFn,
134+
fetchFn: withFetchPreconnect(fetchFn),
135135
});
136136

137137
expect(fetchFn).toHaveBeenCalledWith(
@@ -158,7 +158,7 @@ describe("resolveGraphChatId", () => {
158158
const result = await resolveGraphChatId({
159159
botFrameworkConversationId: "8:orgid:user-object-id",
160160
tokenProvider,
161-
fetchFn,
161+
fetchFn: withFetchPreconnect(fetchFn),
162162
});
163163

164164
expect(fetchFn).toHaveBeenCalledOnce();
@@ -178,7 +178,7 @@ describe("resolveGraphChatId", () => {
178178
botFrameworkConversationId: "a:1unknown_dm",
179179
userAadObjectId: "some-user",
180180
tokenProvider,
181-
fetchFn,
181+
fetchFn: withFetchPreconnect(fetchFn),
182182
});
183183

184184
expect(result).toBeNull();
@@ -197,7 +197,7 @@ describe("resolveGraphChatId", () => {
197197
botFrameworkConversationId: "a:1some_dm_id",
198198
userAadObjectId: "some-user",
199199
tokenProvider,
200-
fetchFn,
200+
fetchFn: withFetchPreconnect(fetchFn),
201201
});
202202

203203
expect(result).toBeNull();

extensions/msteams/src/monitor-handler.file-consent.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,12 @@ function createConsentInvokeHarness(params: {
138138
contentType: "text/plain",
139139
conversationId: params.pendingConversationId ?? "19:[email protected]",
140140
});
141-
const handler = registerMSTeamsHandlers(createActivityHandler(), createDeps());
141+
const handler = registerMSTeamsHandlers(
142+
createActivityHandler(),
143+
createDeps(),
144+
) as MSTeamsActivityHandler & {
145+
run: NonNullable<MSTeamsActivityHandler["run"]>;
146+
};
142147
const { context, sendActivity } = createInvokeContext({
143148
conversationId: params.invokeConversationId,
144149
uploadId,

extensions/qwen-portal-auth/refresh.test.ts

Lines changed: 63 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { afterEach, describe, expect, it, vi } from "vitest";
2+
import { withFetchPreconnect } from "../../test/helpers/extensions/fetch-mock.js";
23
import { refreshQwenPortalCredentials } from "./refresh.js";
34

45
function expiredCredentials() {
@@ -22,18 +23,20 @@ describe("refreshQwenPortalCredentials", () => {
2223
const runRefresh = async () => await refreshQwenPortalCredentials(expiredCredentials());
2324

2425
it("refreshes oauth credentials and preserves existing refresh token when absent", async () => {
25-
globalThis.fetch = vi.fn(async () => {
26-
return new Response(
27-
JSON.stringify({
28-
access_token: "new-access",
29-
expires_in: 3600,
30-
}),
31-
{
32-
status: 200,
33-
headers: { "Content-Type": "application/json" },
34-
},
35-
);
36-
}) as typeof fetch;
26+
globalThis.fetch = withFetchPreconnect(
27+
vi.fn(async () => {
28+
return new Response(
29+
JSON.stringify({
30+
access_token: "new-access",
31+
expires_in: 3600,
32+
}),
33+
{
34+
status: 200,
35+
headers: { "Content-Type": "application/json" },
36+
},
37+
);
38+
}),
39+
);
3740

3841
const result = await runRefresh();
3942

@@ -51,48 +54,52 @@ describe("refreshQwenPortalCredentials", () => {
5154
});
5255

5356
it("replaces the refresh token when the server rotates it", async () => {
54-
globalThis.fetch = vi.fn(async () => {
55-
return new Response(
56-
JSON.stringify({
57-
access_token: "new-access",
58-
refresh_token: "rotated-refresh",
59-
expires_in: 1200,
60-
}),
61-
{
62-
status: 200,
63-
headers: { "Content-Type": "application/json" },
64-
},
65-
);
66-
}) as typeof fetch;
57+
globalThis.fetch = withFetchPreconnect(
58+
vi.fn(async () => {
59+
return new Response(
60+
JSON.stringify({
61+
access_token: "new-access",
62+
refresh_token: "rotated-refresh",
63+
expires_in: 1200,
64+
}),
65+
{
66+
status: 200,
67+
headers: { "Content-Type": "application/json" },
68+
},
69+
);
70+
}),
71+
);
6772

6873
const result = await runRefresh();
6974

7075
expect(result.refresh).toBe("rotated-refresh");
7176
});
7277

7378
it("rejects invalid expires_in payloads", async () => {
74-
globalThis.fetch = vi.fn(async () => {
75-
return new Response(
76-
JSON.stringify({
77-
access_token: "new-access",
78-
expires_in: 0,
79-
}),
80-
{
81-
status: 200,
82-
headers: { "Content-Type": "application/json" },
83-
},
84-
);
85-
}) as typeof fetch;
79+
globalThis.fetch = withFetchPreconnect(
80+
vi.fn(async () => {
81+
return new Response(
82+
JSON.stringify({
83+
access_token: "new-access",
84+
expires_in: 0,
85+
}),
86+
{
87+
status: 200,
88+
headers: { "Content-Type": "application/json" },
89+
},
90+
);
91+
}),
92+
);
8693

8794
await expect(runRefresh()).rejects.toThrow(
8895
"Qwen OAuth refresh response missing or invalid expires_in",
8996
);
9097
});
9198

9299
it("turns 400 responses into a re-authenticate hint", async () => {
93-
globalThis.fetch = vi.fn(
94-
async () => new Response("bad refresh", { status: 400 }),
95-
) as typeof fetch;
100+
globalThis.fetch = withFetchPreconnect(
101+
vi.fn(async () => new Response("bad refresh", { status: 400 })),
102+
);
96103

97104
await expect(runRefresh()).rejects.toThrow("Qwen OAuth refresh token expired or invalid");
98105
});
@@ -110,25 +117,27 @@ describe("refreshQwenPortalCredentials", () => {
110117
});
111118

112119
it("rejects missing access tokens", async () => {
113-
globalThis.fetch = vi.fn(async () => {
114-
return new Response(
115-
JSON.stringify({
116-
expires_in: 3600,
117-
}),
118-
{
119-
status: 200,
120-
headers: { "Content-Type": "application/json" },
121-
},
122-
);
123-
}) as typeof fetch;
120+
globalThis.fetch = withFetchPreconnect(
121+
vi.fn(async () => {
122+
return new Response(
123+
JSON.stringify({
124+
expires_in: 3600,
125+
}),
126+
{
127+
status: 200,
128+
headers: { "Content-Type": "application/json" },
129+
},
130+
);
131+
}),
132+
);
124133

125134
await expect(runRefresh()).rejects.toThrow("Qwen OAuth refresh response missing access token");
126135
});
127136

128137
it("surfaces non-400 refresh failures", async () => {
129-
globalThis.fetch = vi.fn(
130-
async () => new Response("gateway down", { status: 502 }),
131-
) as typeof fetch;
138+
globalThis.fetch = withFetchPreconnect(
139+
vi.fn(async () => new Response("gateway down", { status: 502 })),
140+
);
132141

133142
await expect(runRefresh()).rejects.toThrow("Qwen OAuth refresh failed: gateway down");
134143
});

src/config/zod-schema.core.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ export const ModelCompatSchema = z
195195
thinkingFormat: z
196196
.union([
197197
z.literal("openai"),
198-
z.literal("openrouter"),
199198
z.literal("zai"),
200199
z.literal("qwen"),
201200
z.literal("qwen-chat-template"),

src/gateway/model-pricing-cache.test.ts

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { afterEach, beforeEach, describe, expect, it } from "vitest";
22
import { modelKey } from "../agents/model-selection.js";
33
import type { OpenClawConfig } from "../config/config.js";
4+
import { withFetchPreconnect } from "../test-utils/fetch-mock.js";
45
import {
56
__resetGatewayModelPricingCacheForTest,
67
collectConfiguredModelPricingRefs,
@@ -108,48 +109,50 @@ describe("model-pricing-cache", () => {
108109
},
109110
} as unknown as OpenClawConfig;
110111

111-
const fetchImpl: typeof fetch = async () =>
112-
new Response(
113-
JSON.stringify({
114-
data: [
115-
{
116-
id: "anthropic/claude-opus-4.6",
117-
pricing: {
118-
prompt: "0.000005",
119-
completion: "0.000025",
120-
input_cache_read: "0.0000005",
121-
input_cache_write: "0.00000625",
112+
const fetchImpl = withFetchPreconnect(
113+
async () =>
114+
new Response(
115+
JSON.stringify({
116+
data: [
117+
{
118+
id: "anthropic/claude-opus-4.6",
119+
pricing: {
120+
prompt: "0.000005",
121+
completion: "0.000025",
122+
input_cache_read: "0.0000005",
123+
input_cache_write: "0.00000625",
124+
},
122125
},
123-
},
124-
{
125-
id: "anthropic/claude-sonnet-4.6",
126-
pricing: {
127-
prompt: "0.000003",
128-
completion: "0.000015",
129-
input_cache_read: "0.0000003",
126+
{
127+
id: "anthropic/claude-sonnet-4.6",
128+
pricing: {
129+
prompt: "0.000003",
130+
completion: "0.000015",
131+
input_cache_read: "0.0000003",
132+
},
130133
},
131-
},
132-
{
133-
id: "x-ai/grok-4.20-experimental-beta-0304-reasoning",
134-
pricing: {
135-
prompt: "0.000002",
136-
completion: "0.00001",
134+
{
135+
id: "x-ai/grok-4.20-experimental-beta-0304-reasoning",
136+
pricing: {
137+
prompt: "0.000002",
138+
completion: "0.00001",
139+
},
137140
},
138-
},
139-
{
140-
id: "z-ai/glm-5",
141-
pricing: {
142-
prompt: "0.000001",
143-
completion: "0.000004",
141+
{
142+
id: "z-ai/glm-5",
143+
pricing: {
144+
prompt: "0.000001",
145+
completion: "0.000004",
146+
},
144147
},
145-
},
146-
],
147-
}),
148-
{
149-
status: 200,
150-
headers: { "Content-Type": "application/json" },
151-
},
152-
);
148+
],
149+
}),
150+
{
151+
status: 200,
152+
headers: { "Content-Type": "application/json" },
153+
},
154+
),
155+
);
153156

154157
await refreshGatewayModelPricingCache({ config, fetchImpl });
155158

src/gateway/server.talk-config.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { createEmptyPluginRegistry } from "../plugins/registry-empty.js";
1010
import { getActivePluginRegistry, setActivePluginRegistry } from "../plugins/runtime.js";
1111
import { withEnvAsync } from "../test-utils/env.js";
12+
import { withFetchPreconnect } from "../test-utils/fetch-mock.js";
1213
import { buildDeviceAuthPayload } from "./device-auth.js";
1314
import { validateTalkConfigResult } from "./protocol/index.js";
1415
import {
@@ -273,7 +274,7 @@ describe("gateway talk.config", () => {
273274
}
274275
return new Response(new Uint8Array([1, 2, 3]), { status: 200 });
275276
});
276-
globalThis.fetch = fetchMock as typeof fetch;
277+
globalThis.fetch = withFetchPreconnect(fetchMock);
277278

278279
try {
279280
await withServer(async (ws) => {
@@ -327,7 +328,7 @@ describe("gateway talk.config", () => {
327328
fetchUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
328329
return new Response(new Uint8Array([4, 5, 6]), { status: 200 });
329330
});
330-
globalThis.fetch = fetchMock as typeof fetch;
331+
globalThis.fetch = withFetchPreconnect(fetchMock);
331332

332333
try {
333334
await withServer(async (ws) => {

0 commit comments

Comments
 (0)