fix(discovery): getAvailableModels 缺少 spaceId 导致模型列表永久回落内置表 - #14
Open
gxmst wants to merge 1 commit into
Open
Conversation
`fetchAvailableModelsMetadata` 给 `getAvailableModels` 发的是空 body `{}`,
上游一律返回 400 ValidationError。调用方用 `if err == nil` 吞掉了这个错误,
所以失败没有任何征兆:`meta.Models` 恒为空,模型列表永久回落到
`builtinModelDefinitions()` 的内置表,自动同步实际上从未生效。
该接口要求 `spaceId`。补上之后可正常返回账号的完整模型目录。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
fetchAvailableModelsMetadata调用getAvailableModels时传的是空 body{},上游一律返回:调用处用
if err == nil吞掉了这个错误:所以失败是完全静默的 ——
meta.Models恒为空,cfg.Models永远不会被写入,模型列表无条件回落到builtinModelDefinitions()的内置表。也就是说自动同步从来没有生效过,日志里也看不到任何线索。原因
getAvailableModels要求spaceId参数。实测各种 body 形态:{}{"space_id": ...}{"spaceIds": [...]}{"spaceId": ...}改动
fetchAvailableModelsMetadata增加spaceID参数并放进请求体。调用点传meta.SpaceID—— 此处loadUserContent/getSpacesInitial已经执行完,该字段可用。spaceID为空时直接返回 error,避免再发一次注定 400 的请求。调用方本来就忽略错误,因此没有行为回归。验证
go test ./internal/app/通过config.models为空,/v1/models返回 13 个内置模型/v1/models返回 28 个(内置 + 上游合并去重)同时暴露出内置表已有两处过期数据,本 PR 未改动,仅作记录:
opus-4.7的apricot-sorbet-medium,上游当前为apricot-sorbet-highfireworks-minimax-m2.5已不在目录中,调用返回 502注:仅在单个账号上验证(商用体验版)。不同 plan 返回的目录会不同,但
spaceId缺失时报的是 ValidationError 而非权限错误,与 plan 无关。本 PR 不改变同步时机,仍然只在账号导入/发现时刷新。
🤖 Generated with Claude Code