Skip to content

区分 Gemini 上游 403 的 TOS_VIOLATION 与地区限制 - #1968

Open
dofastted wants to merge 2 commits into
devfrom
cursor/gemini-403-tos-upstream-reason-fc54
Open

dofastted wants to merge 2 commits into
devfrom
cursor/gemini-403-tos-upstream-reason-fc54

Conversation

@dofastted

@dofastted dofastted commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

上游 HTTP 403 不再一律映射为 gemini_location_unsupported。在 scripts/gemini_host_native.py 与 src/lib/gemini/direct-client.mjs 的 _map_worker_error / mapCragWorkerError 中读取载荷 upstream_reason(及 message/error 中的原因 token),与 CRAGGemini 0.4.14+ 前向兼容。

Refs #1957

Error code 决策

  • upstream_reason: TOS_VIOLATION(或错误文本中包含该 token)→ gemini_account_ineligible(沿用既有码,不新增)。该码已在 scheduler.mjs 的 FAILOVER_ERRORS、ACCOUNT_WIDE_COOLDOWN_ERRORS 与 INELIGIBLE_STATES(ineligible)中,单账号熔断与账号级冷却行为与资格不合格一致。
  • upstream_reason: UNSUPPORTED_REGION → gemini_location_unsupported(不变)。
  • 裸 403(无 reason) → gemini_location_unsupported(调度行为不变);用户文案同时说明「账号可能被停用」与「出口地区可能不受支持」,并提示资格查询可能仍正常、应以实际对话确认。

TOS 路径前提:仅当 CRAGGemini worker 透传 upstream_reason,或 message/error 文本本身包含 TOS_VIOLATION 时才会走 TOS → gemini_account_ineligible 分支;否则仍按裸 403 处理为 gemini_location_unsupported。TOS 分支要等 CRAGGemini 透传后才在生产生效。

gemini_account_ineligible 的用户文案不硬断言 TOS:该码亦来自 classify_http_error 的 else 分支、诊断日志 Account ineligible: … 等;文案表述「不符合资格或可能已停用」,仅在文案中条件性提及 TOS_VIOLATION。

gemini_host_account.py 对显式 TOS_VIOLATION 与 assist ineligibleTiers 做了对齐。parse_ineligibility 在没有 tier 时会把 TOS 账号标成 ineligible 并挡出调度;目前没有单测覆盖这条路径。

Release notes(≥ 1.4.237)

  • Gemini 上游 403 在可识别 TOS_VIOLATION 时映射为 gemini_account_ineligible,面板与 API 提示申诉或换号(不硬断言 TOS),不再误导向仅换代理。
  • 裸 403 与 UNSUPPORTED_REGION 的 gemini_location_unsupported 文案说明停用与地区两种可能,并强调以实际对话验证。
  • TOS 映射依赖 CRAGGemini 透传 upstream_reason(或错误文本含 TOS_VIOLATION);无 tier 的 TOS 账号会被标为 ineligible 并挡出调度(该路径暂无单测)。

未验证

测试

  • python3 test/unit/gemini-host-native-smoke.py — PASS
  • node scripts/run-isolated-tests.mjs test/unit .test.mjs gemini-session-conflict — 8/8 PASS
  • pnpm -C web test src/lib/gemini-account-status.test.ts — 14/14 PASS
  • ./node_modules/.bin/biome check --write on 根目录 touched .mjs(Biome 2.5.11);pnpm -C web exec prettier --write on touched web TS

未声称 path-filtered CI run 45954686034 为 dev tip 全量 CI。

Open in Web Open in Cursor 

Note

Medium Risk
Changes error-code mapping and user-facing failover paths for all Gemini 403 upstream responses; wrong reason parsing could mis-route accounts to proxy changes vs account appeals.

Reviewed by Cursor Bugbot for commit f500f5f. Configure here.

Read CRAGGemini upstream_reason on effective 403 in native and direct-client
mappers; route TOS_VIOLATION to gemini_account_ineligible and align host, API,
scheduler, and web remediation copy so bare 403s mention both disable and region.

Co-authored-by: ted <kuhlmangarry24@gmail.com>
@cursor

cursor Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: f17f774c-5554-46ce-a48a-035b4f90f427)

…rder

Soften gemini_account_ineligible messaging across API, scheduler, and web;
order upstream 403 token extraction with TOS first; tighten string checks.

Co-authored-by: ted <kuhlmangarry24@gmail.com>
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.

2 participants