Skip to content

Commit f559898

Browse files
committed
fix(oauth): clamp a dangling legacy model key in secondary_model too
1 parent 4bb8328 commit f559898

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

packages/oauth/src/refreshProviderModels.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,11 @@ function clampDanglingDefault(config: PythinkerConfigShape): void {
327327
function clampDanglingSecondaryModel(config: PythinkerConfigShape): void {
328328
const section = config.secondaryModel;
329329
if (section === undefined) return;
330-
const bound = section.defaultModel ?? section.model;
331-
if (bound !== undefined && readModel(config, bound) === undefined) {
332-
config.secondaryModel = undefined;
333-
return;
330+
for (const bound of [section.defaultModel, section.model]) {
331+
if (bound !== undefined && readModel(config, bound) === undefined) {
332+
config.secondaryModel = undefined;
333+
return;
334+
}
334335
}
335336
if (section.models === undefined) return;
336337
const models = Object.fromEntries(

packages/oauth/test/models-dev-refresh.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,21 @@ describe('refreshProviderModels modelsDev directory providers', () => {
241241
expect(patch.secondaryModel).toBeUndefined();
242242
});
243243

244+
it('clears secondary_model when only the legacy model key dangles beside a valid default_model', async () => {
245+
vi.stubGlobal(
246+
'fetch',
247+
vi.fn(async () => jsonResponse({ 'brand-new-guy': makeDocument()['brand-new-guy'] })),
248+
);
249+
const base = makeBaseConfig();
250+
base.models = { ...base.models, 'other/kept': { provider: 'other', model: 'kept' } };
251+
base.secondaryModel = { defaultModel: 'other/kept', model: `${PROVIDER_ID}/deepseek-v4-flash` };
252+
253+
const { host, calls } = makeHost(base);
254+
await refreshProviderModels(host);
255+
256+
expect(lastPatch(calls).secondaryModel).toBeUndefined();
257+
});
258+
244259
it('prunes vanished pool entries from secondary_model but keeps the rest of the pool', async () => {
245260
vi.stubGlobal(
246261
'fetch',

0 commit comments

Comments
 (0)