Skip to content

fix(#459): report model_not_supported instead of misleading 404 interface-not-found - #632

Open
wylovelyi wants to merge 4 commits into
spring-ai-alibaba:mainfrom
wylovelyi:fix/issue-459-model-not-supported-message
Open

wylovelyi wants to merge 4 commits into
spring-ai-alibaba:mainfrom
wylovelyi:fix/issue-459-model-not-supported-message

Conversation

@wylovelyi

Copy link
Copy Markdown

What this PR does

Closes #459 — when testing a model connection, if the configured model is not supported, the provider returns 404 with body "code":"model_not_supported". But ModelConfigOpsService.parseErrorMessage matched the generic 404 branch first and showed the misleading message "接口未找到 (404),请检查 Base URL 或者路径配置地址", which sends users down the wrong path (they think the URL/path is wrong, not the model).

Root cause

In parseErrorMessage, the order of checks was:

  1. 401 → auth error
  2. 404 → "interface not found" ← matched first for the unsupported-model 404
  3. 429 → quota
  4. else → original message

Since the unsupported-model response is a 404, it was caught by step 2 and never surfaced model_not_supported.

Fix

  • Added a model_not_supported check before the generic 404 branch. It matches both the error code (model_not_supported) and the message text (unsupported model, case-insensitive), and returns a clear "模型不支持 (model_not_supported):请确认模型名称正确,且当前厂商/兼容模式支持该模型。"
  • A plain 404 (genuinely wrong Base URL / path) still reports "接口未找到" as before — no regression for that case.
  • Made parseErrorMessage package-private (was private) so it can be unit-tested directly, and added 4 cases to ModelConfigOpsServiceTest: model_not_supported, generic 404 regression guard, 401, 429.

Files changed

File Change
.../service/aimodelconfig/ModelConfigOpsService.java model_not_supported detection before 404; parseErrorMessage → package-private
.../service/aimodelconfig/ModelConfigOpsServiceTest.java 4 new parseErrorMessage test cases

Note

Only error-message mapping logic changed; no DB schema, no API contract, no behavior change beyond the corrected message.

@wylovelyi

Copy link
Copy Markdown
Author

@zxuexingzhijie 你好,这个 PR 在模型不支持时返回 model_not_supported 而非误导性的 404(#459)。准备好 review 了,谢谢!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 异常提示信息有误

1 participant