Skip to content

fix(llm): stop dumping HTML gateway bodies into provider errors - #36359

Closed
1837620622 wants to merge 1 commit into
anomalyco:devfrom
1837620622:fix/sanitize-provider-html-errors
Closed

fix(llm): stop dumping HTML gateway bodies into provider errors#36359
1837620622 wants to merge 1 commit into
anomalyco:devfrom
1837620622:fix/sanitize-provider-html-errors

Conversation

@1837620622

Copy link
Copy Markdown

Issue for this PR

Closes#35640

Type of change

  • Bug fix

What does this PR do?

When a provider (or proxy) returns an HTML error page such as nginx HTTP 503, the V2 TUI retry notice prints the entire HTML document inline:

Retry attempt 3 scheduled: Provider request failed with HTTP 503: <html>...

Confirmed root causes:

  1. packages/llm/src/route/executor.tsproviderMessage() appends response bodies ≤ 500 characters with no HTML detection
  2. packages/opencode/src/provider/error.ts — if HTML is already embedded in APICallError.message, the existing responseBody HTML guards never run

Minimal fix (aligned with V1 #15406 intent):

LocationChange
RequestExecutor.providerMessageSkip HTML / oversized bodies → Provider request failed with HTTP {status}
ProviderError.messageDetect HTML in message or body; 502/503/504 → Provider temporarily unavailable (HTTP …)
executor.test.tsRegression: nginx-style 503 HTML never appears in reason.message

Plain-text short bodies (e.g. "busy") still surface as before.

How did you verify your code works?

Author

  • GitHub: @1837620622 (传康Kk)
  • Commit email: 35034498+1837620622@users.noreply.github.com (GitHub-verified)

Checklist

  • Linked issue
  • No unrelated changes

V2 TUI retry notices can print full nginx HTML pages when a provider
returns HTTP 503 with an HTML body (issue anomalyco#35640).
Root cause:
- RequestExecutor.providerMessage appends response bodies <= 500 chars
without detecting HTML/gateway pages
- ProviderError.message() can also surface HTML already embedded in
APICallError.message before responseBody HTML guards run
Minimal fix:
- Omit HTML (and oversized) bodies from providerMessage
- Harden ProviderError.message for HTML in msg/responseBody, with
clear 502/503/504 copy
- Add executor regression test for nginx-style 503 HTML
Fixesanomalyco#35640
@1837620622

Copy link
Copy Markdown
Author

Ready for review

Minimal fix for #35640 (raw nginx HTML in V2 TUI retry notices).

  • Source: providerMessage was appending bodies ≤500 chars without HTML detection
  • Defense in depth in ProviderError.message for already-embedded markup
  • Keeps short plain-text provider bodies (e.g. "busy")

Happy to tweak copy if maintainers prefer a different 503 phrasing.

@1837620622

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

I found a potentially related PR:

Related PR:

The other results (PR #34010 about response stream errors and PR #24218 about reasoning models) appear to be related to different aspects of provider/LLM handling and don't seem to be duplicates of the current PR.

@1837620622

Copy link
Copy Markdown
Author

Review ping 🙏

Stops nginx/HTML gateway bodies from being inlined into provider/TUI retry errors (#35640). Regression test included; checks green.

@1837620622

CreatorGhost added a commit to CreatorGhost/TheCode that referenced this pull request Jul 12, 2026
CreatorGhost added a commit to CreatorGhost/TheCode that referenced this pull request Jul 12, 2026
CreatorGhost added a commit to CreatorGhost/TheCode that referenced this pull request Jul 12, 2026
* fix(llm): stop dumping HTML gateway bodies into provider errors
Ported from upstream anomalyco#36359.
* fix(provider): anchor HTML-body detection and fix dcode auth hint
Addresses Opus review of PR #26: isHtmlMarkup was unanchored so a real error
message mentioning <html> was misclassified as a gateway page and discarded;
anchor it like the executor's detector. Also fix the 401 hint to say
'dcode auth login' (was 'opencode'). Adds error.ts regression tests.
@1837620622

Copy link
Copy Markdown
Author

Gentle follow-up

Still ready for review.

Stops nginx/HTML gateway bodies from being inlined into provider/TUI retry errors (#35640). Regression test included; checks green.

Thanks!

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

V2 TUI: retry notice renders raw HTML from provider 503

1 participant

@1837620622