You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "mikemikimike (via GitHub)" <gi...@apache.org> on 2026/08/23 08:56:49 UTC

[PR] fix(core): preserve fallback models after failed discovery [maka]

mikemikimike opened a new pull request, #3581:
URL: https://github.com/apache/maka/pull/3581

   ## Summary
   
   Fixes the independent fallback-model half of #3320.
   
   When model discovery has failed or has not run yet, the catalog can contain an empty `models: []` array without a successful `modelSource`. The picker treated that empty array as authoritative and hid the static fallback catalog, even though the connection could still use the configured fallback model.
   
   This change:
   
   - infers `fallback`, rather than `fetched`, for an empty model array when no source is persisted;
   - keeps fallback models visible for failed/pending discovery;
   - preserves an explicitly fetched empty inventory as authoritative;
   - adds regression coverage for both states.
   
   The URL-normalization question in #3320 is intentionally out of scope.
   
   ## Validation
   
   - `npm --workspace @maka/core run typecheck`
   - `npm --workspace @maka/core run build`
   - `npm --workspace @maka/core run test:dist` — 638 passed
   - `npx biome check packages/core/src/model-catalog.ts packages/core/src/__tests__/model-catalog.test.ts`
   - `npx biome lint packages/core/src/model-catalog.ts packages/core/src/__tests__/model-catalog.test.ts`
   - `git diff --check`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(core): preserve fallback models after failed discovery [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3581:
URL: https://github.com/apache/maka/pull/3581#discussion_r3839481078


##########
packages/core/src/model-catalog.ts:
##########
@@ -179,12 +179,17 @@ export function buildModelCatalogEntries(input: BuildModelCatalogInput): ModelCa
   const normalizedDefaultModel = input.defaultModel?.trim();
   const recommendedRanks = recommendedRanksForProvider(input.providerType, input.fallbackModels);
   const source = inventory === 'live' ? 'provider_api' : 'static_catalog';
+  // An empty array without a successful discovery source is the persisted
+  // shape of a failed or not-yet-run discovery. It must not hide the static
+  // fallback catalog from the picker. An empty fetched array is different: it
+  // is an authoritative provider response and should remain empty.
   const rawModels =
-    liveModels ??
-    (input.fallbackModels ?? []).map((id) => ({
-      id,
-      ...displayNameForKnownModel(input.providerType, id),
-    }));
+    liveModels !== undefined && (liveModels.length > 0 || modelSource === 'fetched')
+      ? liveModels
+      : (input.fallbackModels ?? []).map((id) => ({
+          id,

Review Comment:
   [P3] Pre-existing, not introduced here (anchored to this hunk because the affected line at `:270` is unchanged and cannot take an inline comment) — but it sits directly adjacent to what this PR fixes, so it is worth naming while the area is being touched.
   
   A connection that **succeeded** at discovery (`modelSource === 'fetched'`) but whose models were all later quarantined ends up here with `[]` after the filter, still carrying `'fetched'`. That takes the "authoritatively empty" branch, so the picker renders empty and no fallback catalog is offered — even though the static fallback may contain usable models.
   
   Trigger → path → outcome: a connection works normally, every one of its model ids later lands in `brokenModelIds`, the user opens the model picker and sees **nothing**.
   
   From the user's side this is indistinguishable from the failed-discovery case this PR is fixing, but only the latter is covered. Behavior is unchanged from before this PR (the old code also reduced to `rawModels = liveModels = []` here), so this is not a regression — hence P3 rather than a blocker.
   
   Smallest fix: check for emptiness *after* filtering — if the pre-filter list was non-empty and the post-filter list is empty, treat it as having no usable discovery result and fall back. A production-seam test would set `models` such that every id hits `brokenModelIds` with `modelSource: 'fetched'`, and assert fallback catalog entries are still returned.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(core): preserve fallback models after failed discovery [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #3581:
URL: https://github.com/apache/maka/pull/3581#issuecomment-5393082232

   LGTM,合并中。
   
   CI 之前一直卡在 fork 待批准状态,我放行后在当前 head `db2e2aa9e` 上跑绿了。另外我把它试合并进最新的 main 验证过:和 main 没有重叠改动,合并后 core 构建干净、`model-catalog` 13 项测试全过。
   
   唯一还开着的那条线程是我自己标的 P3,已注明是既有问题、不是这个 PR 引入的,不挡合并。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(core): preserve fallback models after failed discovery [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han merged PR #3581:
URL: https://github.com/apache/maka/pull/3581


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org