Skip to content

fix(google): preserve upstream error precedence for location denials (carry of #3547) - #3608

Merged
lidge-jun merged 3 commits into
devfrom
codex/260905-location-precedence-carry
Sep 5, 2026
Merged

fix(google): preserve upstream error precedence for location denials (carry of #3547)#3608
lidge-jun merged 3 commits into
devfrom
codex/260905-location-precedence-carry

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Summary

Carries #3547 / #3469 and fixes the concrete error-precedence blocker. Google location inference is restricted to the observed 400/precondition envelope; 5xx remains a server failure and explicit PERMISSION_DENIED retains its permission classification. Message-only terminals retain bounded location inference.

Verification

  • Astra worker typecheck and static diff checks passed.
  • Regression assertions cover mixed 503/location wording and explicit permission enums.
  • No local tests run. Final dev Linux CI is the batch gate.

Checklist

  • Scoped classification carry and real blocker correction.
  • Existing upstream status handling retained.
  • No token or credential changes.

Co-authored-by: agentHits zvercombat26rus@icloud.com

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of unsupported geographic and datacenter locations.
    • These errors are now reported as permission errors with the location_not_supported code instead of generic invalid-request errors.
    • Preserved upstream HTTP 400 responses where applicable and inferred HTTP 403 for terminal message-only errors.
    • Location restrictions are not bypassed, and affected requests are not retried unnecessarily.
  • Documentation

    • Updated adapter documentation to clarify location restriction behavior and error reporting.

jun and others added 3 commits September 5, 2026 07:52
…ot an invalid request

Google Cloud Code Assist (Antigravity) and Vertex reject unsupported geographic or
datacenter locations with HTTP 400 FAILED_PRECONDITION "User location is not supported
for the API use." classifyGoogle folded every 400 into "invalid request", and the shared
classifier then emitted invalid_request_error — telling the user their prompt was
malformed when the network location was refused.

- classifyGoogle: new "location not supported" branch after auth/quota/permission enums
  and before the generic 400 fallthrough, so UNAUTHENTICATED / RESOURCE_EXHAUSTED /
  PERMISSION_DENIED keep precedence.
- classifyError: location denials map to permission_error / location_not_supported,
  placed after the authoritative 401 block.
- inferHttpStatusFromAdapterMessage: message-only terminals infer 403 so they agree with
  the classified envelope instead of falling through to 502.
- Direct HTTP responses keep the upstream 400.

Carries PR #3469 with the precedence fix and without the VPN/TUN console warning.

Closes #3467

Co-authored-by: agentHits <zvercombat26rus@icloud.com>
Restrict Google location inference to 400 precondition envelopes and preserve 5xx and explicit PERMISSION_DENIED classification. Add regression assertions without running local tests.

Co-authored-by: agentHits <zvercombat26rus@icloud.com>
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 5, 2026 03:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T03:50:58.216880Z 1d47274 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: ed33e277-a064-4dc4-a61d-b8530be0b68e

📥 Commits

Reviewing files that changed from the base of the PR and between 9c44963 and 1d47274.

📒 Files selected for processing (6)
  • docs-site/src/content/docs/reference/adapters.md
  • src/adapters/google-errors.ts
  • src/lib/errors.ts
  • tests/adapters/google/google-errors.test.ts
  • tests/adapters/google/google-vertex-http.test.ts
  • tests/server/error-fidelity.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The change adds detection and classification for unsupported Google geographic or datacenter locations. It preserves direct HTTP 400 responses, infers HTTP 403 for message-only paths, keeps higher-priority errors authoritative, and prevents retries.

Changes

Google location denial handling

Layer / File(s) Summary
Shared location error classification
src/lib/errors.ts, tests/server/error-fidelity.test.ts
Location-denial messages map to permission_error with code location_not_supported. Non-5xx location errors infer HTTP 403 for message-only paths. Authentication, rate-limit, explicit permission, and authoritative 5xx statuses retain precedence.
Google adapter classification
src/adapters/google-errors.ts, tests/adapters/google/google-errors.test.ts, tests/adapters/google/google-vertex-http.test.ts
Google HTTP 400 FAILED_PRECONDITION responses with location wording return a location-not-supported message. The adapter preserves status 400 and does not retry the request.
Documented location behavior
docs-site/src/content/docs/reference/adapters.md
The adapter reference documents location classification, status inference, and the absence of proxy rerouting.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 1d472

Google location denials are now reported as location-not-supported permission errors without changing authoritative HTTP statuses or retry behavior. No concrete current-head merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant GoogleAPI
  participant GoogleAdapter
  participant ErrorClassifier
  participant ProxyResponse
  GoogleAPI->>GoogleAdapter: HTTP 400 FAILED_PRECONDITION with location text
  GoogleAdapter->>ErrorClassifier: classify location denial
  ErrorClassifier-->>GoogleAdapter: location_not_supported
  GoogleAdapter-->>ProxyResponse: preserve HTTP 400
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: Google location-denial classification while preserving upstream error precedence. The carry reference is supplementary and does not make the title mislead…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/260905-location-precedence-carry

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d47274769

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/errors.ts
}
// Location denials outrank generic permission / subscription wording, but never an
// authoritative 5xx. Message-only adapter terminals arrive here with inferred 403.
if (status < 500 && (type === "location_not_supported" || isLocationUnsupportedMessage(text))) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve explicit Google enums through final classification

When Vertex or Antigravity returns PERMISSION_DENIED or INVALID_ARGUMENT with location wording, safeGoogleHttpErrorMessage correctly normalizes it to access denied or invalid request, but the enum itself is then discarded. The Responses path subsequently calls classifyError, where this condition matches the retained detail before the generic permission/invalid-request branches, changing both cases to location_not_supported. Thus the precedence asserted by the new Google tests is not preserved in the client-facing envelope; carry the classified reason/code through normalization or recognize the authoritative normalized prefix before applying location inference.

AGENTS.md reference: src/AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

@lidge-jun
lidge-jun merged commit c44e187 into dev Sep 5, 2026
7 of 9 checks passed
@lidge-jun
lidge-jun deleted the codex/260905-location-precedence-carry branch September 5, 2026 03:51
@lidge-jun

Copy link
Copy Markdown
Owner Author

리뷰 · 우선순위 74 / 80

이 PR은 Google Antigravity / Vertex / Gemini 쪽에서 올라오는 “User location is not supported for the API use.” 거절을, 지금 dev HEAD(e44916548, package 2.43.0)가 하던 것처럼 “잘못된 요청(invalid request)”으로 묶지 않고, 권한/위치 거절로 바르게 분류하려는 수정입니다. 이슈 #3467이 가리키는 실제 현상은 HTTP 400 FAILED_PRECONDITION인데, 예전 classifyGoogle은 400을 전부 invalid request로 떨어뜨려서 사용자에게 “프롬프트가 잘못됐다”는 잘못된 신호를 줬습니다.

지금 devsrc/adapters/google-errors.ts에는 아직 위치 전용 분기가 없고, src/lib/errors.ts에도 isLocationUnsupportedMessage가 없습니다. 이 PR은 그 두 곳에 공통 판별기를 두고, Google 쪽에서는 “HTTP 400이면서 enum이 비었거나 FAILED_PRECONDITION일 때만” 위치 추론을 허용합니다. 5xx나 명시적 PERMISSION_DENIED / UNAUTHENTICATED / RESOURCE_EXHAUSTED는 위치 문구가 섞여 있어도 원래 권위를 지킵니다. 직접 HTTP 응답은 업스트림 400을 유지하고, 메시지-only 터미널은 403으로 맞춰 permission_error 봉투와 상태가 어긋나지 않게 합니다.

이 방향은 열린 선행 PR #3547 / #3469보다 한 단계 더 단단합니다. #3547은 위치 문구만 보이면 상태와 관계없이 위치 거절로 올릴 수 있는 형태에 가깝고, 여기 캐리 커밋은 “400 precondition 봉투만 허용 + 권위 있는 5xx/명시 enum 보존”을 테스트로 못 박습니다. 문서(docs-site/.../adapters.md)에도 “프록시가 VPN으로 우회하지 않는다”는 경계를 적어 두어, 분류 수정과 라우팅 우회를 섞지 않습니다.

테스트는 tests/adapters/google/google-errors.test.ts, google-vertex-http.test.ts, tests/server/error-fidelity.test.ts에 회귀를 넣었습니다. 로컬 스위트는 돌리지 않았고 exact-head CI가 게이트라고 명시했습니다. 범위는 분류와 문서·테스트뿐이라 런타임 자격증명이나 라우팅 경로를 건드리지 않습니다.

src/adapters/google-errors.ts - 위치 분기가 auth/quota/permission 다음·overload 앞에 있어 우선순위가 코드 순서와 주석이 일치합니다. 400 + FAILED_PRECONDITION 가드가 핵심입니다.

src/lib/errors.ts - classifyError에서 명시 PERMISSION_DENIED를 위치보다 먼저 처리하고, 위치는 status < 500일 때만 적용합니다. 5xx에 위치 문구가 섞여도 server_error로 남는 계약이 테스트와 맞습니다.

src/lib/errors.ts / inferHttpStatusFromAdapterMessage - 메시지-only는 403, 직접 HTTP는 400을 유지합니다. 의도된 이원 경로이지만 클라이언트마다 다른 상태를 볼 수 있으니, 문서에 이미 적힌 대로 “직접 응답은 업스트림 400 유지”를 릴리즈 노트에도 한 줄 남기면 좋습니다.

라인 없음 - PR 본문에 Closes #3467이 커밋 메시지에만 있고 요약 체크리스트에는 없습니다. 머지 시 이슈·선행 PR(#3547/#3469) 정리 문구를 본문에 명시하는 편이 안전합니다.

메인테이너의 판단이 필요한 지점

  • #3608을 정식 착륙으로 삼고 #3547/#3469를 landed-via-maintainer로 닫을지
  • 직접 HTTP 400 vs 메시지-only 403 이원 상태를 그대로 둘지, 클라이언트 통일을 위해 한쪽을 맞출지
  • exact-head CI만 게이트로 둘지(본문 선언과 동일)

너의 추천
exact-head CI가 초록이면 #3608을 합칩니다. 합친 뒤 #3467을 닫고, 범위가 겹치는 #3547#3469Landed via #3608 코멘트 + landed-via-maintainer로 정리하세요. #3547을 리베이스해 살릴 필요는 없습니다.

이 댓글은 grok-bot이 작성했습니다

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 5, 2026
lidge-jun added a commit that referenced this pull request Sep 5, 2026
Owner-authorized admin squash of child-only #3551 carry onto corrected #3608. Scheme-matched proxy snapshot, explicit proxy transport binding, exact IPv6 prefix and NO_PROXY denial retained. Existing source security assessment and current static/typecheck evidence recorded. No local tests; final dev Linux CI is the batch gate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant