fix(ai): preserve provider access restriction errors by Ehsan-hash · Pull Request #56022 · anomalyco/opencode · GitHub
Skip to content

fix(ai): preserve provider access restriction errors - #56022

Open
Ehsan-hash wants to merge 1 commit into
anomalyco:devfrom
Ehsan-hash:provider-access-errors
Open

Ehsan-hash wants to merge 1 commit into
anomalyco:devfrom
Ehsan-hash:provider-access-errors

Conversation

@Ehsan-hash

@Ehsan-hash Ehsan-hash commented Oct 16, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #55995

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Treat typed RegionError and FreeTierError HTTP 403 refusals as existing invalid-request errors. ACP then preserves the provider's explanation instead of offering a login that cannot fix the refusal. Genuine 401 and other 403 authentication failures keep their existing behavior.

AI-assisted implementation and testing, with independent agent review.

How did you verify your code works?

  • A local HTTP gateway and actual ACP CLI reproduce both refusals on the original classifier. The fix preserves their messages; 401/403 authentication controls stay auth-required. Each prompt makes one provider request, without retries.
  • Full AI suite: 1,817 passed, 28 skipped. Affected Core tests: 12 passed; ACP tests: 50 passed. Focused classifier tests pass, including ten repeated runs.
  • bun run check: lint and all 35 typechecks passed. Prettier and git diff --check passed.

No real model calls or Windows verification.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #47949, #49201, #50366

@github-actions

Copy link
Copy Markdown
Contributor

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. I reproduced #55995 with the issue's script: ACP from source, with a mock gateway answering every request with 403 FreeTierError or 403 RegionError. On the base, session/prompt returned -32000 Authentication required for both. With this change, both return -32603 Internal error: This model is not available in your country (errorName: provider.invalid-request), so the provider's message now reaches the client. The new check only applies to 403s with these two codes, so other 401/403 responses are still treated as authentication failures, and InvalidRequest is not retried. The provider-error tests (39), the ACP tests in packages/cli (100) and the packages/ai typecheck pass.

The public API is unchanged: this only changes how errors are classified inside the code.

Related: #47949, #49201, #50366

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.

Every HTTP 403 is classified as AuthenticationError, so FreeTierError/RegionError reach ACP clients as "Authentication required"

1 participant