From dcd902f3bf00c0758f40740a3644f9558f39aec1 Mon Sep 17 00:00:00 2001 From: can1357 Date: Fri, 24 Jul 2026 01:26:33 +0200 Subject: [PATCH] fix: scoped empty-success catalog authority to alibaba-token-plan fetchProviderModelsFromCatalog returning succeeded=true for an empty discovery made every dynamicModelsAuthoritative provider drop its models.dev and previous-snapshot rows after a flaky empty-but-200 response. Restored the fetched-models requirement for other providers; only alibaba-token-plan treats an empty success as authoritative so the subscribed-edition allowlist is not widened by the curated seed. Also dropped the stray trailing newline in models.json that the generator does not emit. --- packages/catalog/scripts/generate-models.ts | 13 ++++++++++++- packages/catalog/src/models.json | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/catalog/scripts/generate-models.ts b/packages/catalog/scripts/generate-models.ts index 209d0a115..d91174f34 100644 --- a/packages/catalog/scripts/generate-models.ts +++ b/packages/catalog/scripts/generate-models.ts @@ -492,9 +492,20 @@ async function generateModels() { ...(await fetchProviderModelsFromCatalog(descriptor)), })), ); + // A provider is authoritative once its endpoint snapshot can replace the + // models.dev / previous-snapshot rows. Requiring fetched models keeps a + // flaky empty-but-200 discovery from silently wiping another provider's + // bundled catalog; only alibaba-token-plan treats an empty success as + // authoritative, because its `/models` allowlist reflects the subscribed + // edition and must not be widened by the curated seed below. const authoritativeCatalogProviders = new Set( catalogProviderModelBatches - .filter(batch => batch.descriptor.dynamicModelsAuthoritative === true && batch.succeeded) + .filter( + batch => + batch.descriptor.dynamicModelsAuthoritative === true && + (batch.models.length > 0 || + (batch.succeeded && batch.descriptor.providerId === "alibaba-token-plan")), + ) .map(batch => batch.descriptor.providerId), ); const catalogProviderModels = catalogProviderModelBatches.flatMap(batch => batch.models); diff --git a/packages/catalog/src/models.json b/packages/catalog/src/models.json index e8570aa15..00f76c7da 100644 --- a/packages/catalog/src/models.json +++ b/packages/catalog/src/models.json @@ -94800,4 +94800,4 @@ } } } -} +} \ No newline at end of file