Skip to content

Errors: rewrite 403 HTML auth pages - #73635

Closed
sai8341 wants to merge 2 commits into
openclaw:mainfrom
sai8341:fix/openai-codex-html-403-errors
Closed

sai8341 wants to merge 2 commits into
openclaw:mainfrom
sai8341:fix/openai-codex-html-403-errors

Conversation

@sai8341

@sai8341 sai8341 commented Apr 28, 2026 •

Copy link
Copy Markdown

Summary

Fix incorrect user-facing error reporting when provider requests return 403 HTML auth/challenge pages.

Previously these failures could be surfaced as transport or rate-limit style errors, which sent users down the wrong debugging path. This change detects embedded and direct HTML auth pages earlier and keeps them on the authentication failure path instead.

What changed

  • detect embedded/direct HTML HTTP error pages in shared assistant error formatting
  • preserve 403 HTML auth failures as auth-specific runtime classification
  • prefer auth HTML copy before transport/rate-limit rewrites in user-facing sanitizers
  • add regression coverage for formatter, sanitizer, and runtime classification paths

Verification

Passed:

  • pnpm test src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts
  • pnpm test src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts
  • pnpm test src/agents/pi-embedded-helpers.sanitizeuserfacingtext.test.ts
  • pnpm test src/agents/pi-embedded-subscribe.handlers.lifecycle.test.ts

AI-assisted PR.

# Conflicts:
#	src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts
#	src/agents/pi-embedded-helpers/errors.ts
#	src/shared/assistant-error-format.ts
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S triage: blank-template Candidate: PR template appears mostly untouched. triage: refactor-only Candidate: refactor/cleanup-only PR without maintainer context. labels Apr 28, 2026
@greptile-apps

greptile-apps Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR rewrites 403 HTML auth page handling so that embedded 403 <html>… error strings are classified as auth_html_403 and surfaced with a dedicated re-authentication message instead of being misclassified as rate-limit or transport failures. It introduces extractHtmlHttpError in the shared module and threads it through classifyProviderRuntimeFailureKind, formatAssistantErrorText, and sanitizeUserFacingText.

  • P1 – corrupted ellipsis: The change accidentally replaced the … character with the mojibake sequence … on the final fallback line in formatRawAssistantErrorForUi. Every truncated error message (>600 chars) will render garbled text until fixed.

Confidence Score: 3/5

Not safe to merge until the corrupted ellipsis character is fixed — it will produce garbled output in any truncated error message shown to users.

One P1 defect (mojibake ellipsis) is present on the changed path; the new classification logic itself appears sound and is well-covered by the added tests.

src/shared/assistant-error-format.ts — line 260 has a corrupted character introduced by this PR.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/shared/assistant-error-format.ts
Line: 260

Comment:
**Corrupted ellipsis character**

The PR replaced the proper Unicode ellipsis `…` (U+2026) with the mojibake sequence `…`, which is what `…`'s UTF-8 bytes (`E2 80 A6`) look like when decoded as Latin-1. Any error message longer than 600 characters will now display garbled text to the user instead of a clean truncation indicator.

```suggestion
  return trimmed.length > 600 ? `${trimmed.slice(0, 600)}…` : trimmed;
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/agents/pi-embedded-helpers/sanitize-user-facing-text.ts
Line: 368-374

Comment:
**Duplicated helper function**

`shouldPreferHtmlHttpErrorCopy` is defined identically in both this file and `src/agents/pi-embedded-helpers/errors.ts`. Since both callers already import `extractHtmlHttpError` from the shared module, consider exporting this helper from `assistant-error-format.ts` (or a shared utility) and importing it in both places to avoid divergence.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Errors: rewrite 403 HTML auth pages" | Re-trigger Greptile

Comment thread src/shared/assistant-error-format.ts Resolved
@clawsweeper

clawsweeper Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as duplicate/superseded: the branch is stale, conflicting, and targets removed pi-embedded helper paths; generic auth-HTML handling was already merged through #79900, while the remaining Codex/Cloudflare 403 behavior is tracked by #94432 and current-path PRs.

Canonical path: Close this PR and keep #94432 with current-path PRs #94440 and #95150 as the active track for any remaining Codex/Cloudflare work.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this PR and keep #94432 with current-path PRs #94440 and #95150 as the active track for any remaining Codex/Cloudflare work.

Do we have a high-confidence way to reproduce the issue?

Yes for the close decision: live PR metadata, current source, and tracked files prove the branch is obsolete and conflicting; no live Codex OAuth repro was run in this read-only review.

Is this the best way to solve the issue?

No: reviving this old pi-embedded branch is not the best fix because generic auth-HTML behavior already merged and remaining Cloudflare/Codex behavior belongs on the active embedded-agent helper surface.

Security review:

Security review cleared: The diff only changes TypeScript error formatting/classification and tests, with no dependency, workflow, secret, permission, package, or code-execution surface changes.

AGENTS.md: found and applied where relevant.

What I checked:

  • AGENTS policy read: Root AGENTS.md was read fully, along with the scoped agents guide; the applicable policy requires deep source/history review, current-main checks, related PR/issue search, and direct Codex source inspection for Codex-related verdicts. (AGENTS.md:14, d1b917120a47)
  • Live PR state: GitHub reports this PR open at head ef1a908, mergeable=CONFLICTING, mergeStateStatus=DIRTY, with labels requiring real behavior proof and marking auth-provider merge risk. (ef1a908ee817)
  • Stale path proof: The PR diff changes src/agents/pi-embedded-helpers* files, while current main tracks no pi-embedded helper files and uses src/agents/embedded-agent-helpers/* instead. (d1b917120a47)
  • Active classifier behavior: Current main's active classifyProviderRuntimeFailureKind lives in src/agents/embedded-agent-helpers/errors.ts and maps detected status 401/403 HTML responses to auth_html. (src/agents/embedded-agent-helpers/errors.ts:1207, d1b917120a47)
  • Current user-facing copy boundary: Current main distinguishes auth_html re-authentication copy from upstream_html CDN/gateway copy, which is the active behavior the remaining Cloudflare work must change on the current helper surface. (src/agents/embedded-agent-helpers/errors.ts:1418, d1b917120a47)
  • Current regression coverage: Current tests still assert that a plain 403 HTML runtime failure remains auth_html, so the remaining work must distinguish Cloudflare challenge HTML from generic auth HTML on the active test path. (src/agents/embedded-agent-helpers/provider-error-patterns.test.ts:229, d1b917120a47)

Likely related people:

  • martingarramon: Authored merged PR fix(agents): classify auth HTML provider responses #79900, which implemented overlapping generic 401/403 HTML auth classification and regression coverage. (role: auth HTML classification contributor; confidence: high; commits: 7f4462e5c06d; files: src/agents/pi-embedded-helpers/errors.ts, src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts, src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts)
  • altaywtf: Merged PR fix(agents): classify auth HTML provider responses #79900, the overlapping generic auth-HTML implementation that supersedes the useful central part of this older branch. (role: merger and adjacent area contributor; confidence: high; commits: 7f4462e5c06d; files: src/agents/pi-embedded-subscribe.handlers.lifecycle.ts, src/agents/pi-embedded-runner/run/failover-observation.ts)
  • stainlu: Authored merged HTML provider error classification work that established the auth_html versus upstream_html boundary used by the current candidates. (role: HTML provider classification contributor; confidence: high; commits: e588e904a744; files: src/agents/pi-embedded-helpers/errors.ts, src/agents/pi-embedded-helpers/provider-error-patterns.test.ts)
  • chris-yyau: Authored shared formatter changes for Codex/Cloudflare HTML challenge detection and sanitizer behavior adjacent to this PR. (role: adjacent challenge detector contributor; confidence: high; commits: 36dd58ac2a5d, 59caf03d6783; files: src/shared/assistant-error-format.ts, src/agents/pi-embedded-helpers/sanitize-user-facing-text.ts)
  • lin-hongkuan: Current active classifier lines blame to the large import/graft commit that carried the embedded-agent helper path now used on main; this is routing history rather than feature origin. (role: recent file-carrying contributor; confidence: low; commits: 67118d5ab912; files: src/agents/embedded-agent-helpers/errors.ts)

Codex review notes: model internal, reasoning high; reviewed against d1b917120a47.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 30, 2026
@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label May 30, 2026
@barnacle-openclaw barnacle-openclaw Bot removed the stale Marked as stale due to inactivity label May 30, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 14, 2026
@clawsweeper

clawsweeper Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: blank-template Candidate: PR template appears mostly untouched. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. triage: refactor-only Candidate: refactor/cleanup-only PR without maintainer context.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant