fix(shared): stop reporting client refusals as invalid API keys #21486
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 307 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.343
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #21486"
general
weight: 0.35
ggbdpq
What does this PR do?
Gateways that reject third-party clients answer with auth-flavored wording that names the client, not the key — the report's screenshot shows
unauthorized client detected, contact support for assistancefrom the provider, while Cherry's conversation error block headlines "API 密钥无效,请检查后重新配置" / "API Key is invalid, please check and reconfigure". The error classifier files anyunauthorizedtext underauth, so users are sent off regenerating a working key; the same mislabel fires on the model-list probe for providers whose/modelsendpoint is gated (the report's title angle: providers that don't support model-list fetching).This PR recognizes client-refusal wording (
unauthorized client …) as a refusal (permissioncategory): the guidance becomes "The provider refused this request. Check the error details, your account plan, API key permissions, or access to this resource" instead of key-regeneration. Explicit key-invalidity signals (invalid api key,invalid_api_key) still win and classify asauth, and plainUnauthorizedresponses are unaffected.One rule fixes both surfaces: the conversation error diagnosis and the doctor's
provider-model-listprobe shareclassifyErrorCategory.Fixes #21376
Verification table
| Step | Result |
| --- | --- |
|
pnpm vitest run --project shared src/shared/utils/__tests__/errorCategory.test.ts| 19 passed (new cases red on the parent commit: client refusal →permission; explicit key signals and plainUnauthorizedstayauth) || Regression:
--project sharedfull | 113 files / 1690 tests passed || Regression:
--project main src/main/services/diagnostics(doctor probes) | 25 files / 379 tests passed || Regression:
--project renderererror utils | 133 tests passed ||
pnpm check --group types| exit 0 ||
oxfmt --check+oxlinton changed files | clean |AI use
Implemented with GLM-5.3-Flash (ZCode); classification rule, tests, and this PR reviewed by the author.
Checklist
permissiondiagnosis copy in all locales)