Skip to content

fix(mattermost): bound null-body error response reads - #95296

Closed
Pick-cat wants to merge 1 commit into
openclaw:mainfrom
Pick-cat:fix/anthropic-oauth-user-agent-version
Closed

Pick-cat wants to merge 1 commit into
openclaw:mainfrom
Pick-cat:fix/anthropic-oauth-user-agent-version

Conversation

@Pick-cat

@Pick-cat Pick-cat commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Mattermost API error handling could still call unbounded response.json() / response.text() when readMattermostError() saw a response with no readable body stream. That left a narrow follow-up hole after #96033 bounded the successful REST read path.

Why This Change Was Made

readMattermostError() already bounded error bodies when res.body was present, but the !res.body branch fell back to native json() / text(). The helper now always uses readResponseTextLimited (8 KiB) and parses JSON from that bounded text, matching the existing error-path contract without a second buffering strategy.

User Impact

Operators and agents talking to self-hosted or misbehaving Mattermost servers still get the same API error messages on failures, without the plugin buffering arbitrarily large error bodies through the null-body fallback.

Evidence

node scripts/run-vitest.mjs extensions/mattermost/src/mattermost/client.test.ts
Test Files  1 passed (1)
     Tests  27 passed (27)

Added regression tests that:

  • prove null-body JSON errors never call response.json() / response.text()
  • keep parsing bounded JSON message fields from normal response bodies
  • cover guarded null-body failures through createMattermostClient().request()

AI-assisted: implementation and tests were drafted with Cursor agent assistance; validation was run locally with the command above.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts agents Agent runtime and tooling size: M labels Jun 20, 2026
@clawsweeper

clawsweeper Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 25, 2026, 3:08 AM ET / 07:08 UTC.

Summary
The PR adds a shared Claude Code user-agent helper, switches both Anthropic OAuth request builders to it, and documents the invalid-token symptom.

PR surface: Source +5, Tests +45, Docs +11. Total +61 across 7 files.

Reproducibility: yes. for source-level reproduction: current main and v2026.6.10 both emit claude-cli/2.1.75 on the Anthropic OAuth bearer paths. I did not run a credentialed live Anthropic OAuth round-trip.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #94716
Summary: This PR is a candidate fix for the canonical stale Anthropic OAuth claude-cli/2.1.75 user-agent bug; other open PRs target the same root cause, while a separate Claude CLI subprocess 401 report is adjacent but distinct.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦞 diamond lobster
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted terminal, log, or live-output proof from a real patched OpenClaw Anthropic OAuth/subscription run, with tokens, account details, endpoints, and other private data removed.
  • If contributor-side live proof is impossible, have a maintainer document private live validation or explicit acceptance of the proof gap.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body provides terminal/source inspection and targeted tests, but not redacted live output from a real patched OpenClaw Anthropic OAuth/subscription run. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Green CI and source-level checks prove header construction, but they do not prove Anthropic accepts claude-cli/2.1.191 from a real patched OpenClaw OAuth/subscription request.
  • [P1] The static helper removes the current stale constant but still depends on future OpenClaw releases when Anthropic tightens the accepted Claude Code recency window.
  • [P1] Several open PRs target the same canonical issue, so maintainers should choose one landing path before merging competing fixes.

Maintainer options:

  1. Require real OAuth proof (recommended)
    Ask for redacted terminal, log, or live-output proof from a real patched OpenClaw Anthropic OAuth/subscription run before merge.
  2. Maintainer validates privately
    A maintainer with a Claude subscription token can run private live validation and state that they accept the contributor proof gap.
  3. Choose another same-root PR
    If a competing same-root PR becomes the canonical fix, pause or close this PR only after preserving useful context and contributor credit.

Next step before merge

  • [P1] The remaining blocker is live OAuth proof or explicit maintainer acceptance of the proof gap, which automation cannot supply from the contributor's environment.

Security
Cleared: The final diff changes Anthropic OAuth headers, docs, and tests without adding dependencies, scripts, permissions, lifecycle hooks, lockfile changes, or new secret-handling behavior.

Review details

Best possible solution:

Land one canonical fix after redacted live OAuth proof or explicit maintainer validation, then close the linked issue and resolve the competing same-root PRs.

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

Yes for source-level reproduction: current main and v2026.6.10 both emit claude-cli/2.1.75 on the Anthropic OAuth bearer paths. I did not run a credentialed live Anthropic OAuth round-trip.

Is this the best way to solve the issue?

Yes, the current PR shape is a conservative fix: one shared current-version helper covers both OAuth request builders without adding config, subprocess, package-resolution, or dependency surface. The remaining blocker is real OAuth proof or maintainer acceptance, not a line-level code defect.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P1: The PR targets a current Anthropic OAuth bearer-auth failure that can block Claude subscription-backed provider and agent runs.
  • merge-risk: 🚨 auth-provider: The diff changes Anthropic OAuth identity headers, which directly affect whether bearer-token provider requests authenticate successfully.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body provides terminal/source inspection and targeted tests, but not redacted live output from a real patched OpenClaw Anthropic OAuth/subscription run. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +5, Tests +45, Docs +11. Total +61 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 11 6 +5
Tests 3 46 1 +45
Docs 1 11 0 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 68 7 +61

What I checked:

Likely related people:

  • vincentkoc: Git history ties the managed Anthropic transport runtime and OAuth-related provider/docs work to this handle, including the commit that introduced src/agents/anthropic-transport-stream.ts. (role: introduced sibling transport behavior and recent provider contributor; confidence: high; commits: ea4265a82063, 067496b12934, f03ff3975406; files: src/agents/anthropic-transport-stream.ts, src/llm/providers/anthropic.ts, docs/providers/anthropic.md)
  • steipete: Path history shows substantial Anthropic provider and Claude CLI docs work by this handle, and shortlog shows heavy activity on these files. (role: recent adjacent Anthropic docs/provider contributor; confidence: medium; commits: d378a504ac17, 35aafd7ca813, 5c5c82dfaa6f; files: docs/providers/anthropic.md, src/llm/providers/anthropic.ts, src/agents/anthropic-transport-stream.ts)
  • liuhao1024: A recent merged fix changed both the legacy SDK provider and managed Anthropic transport, which are the same sibling request builders touched here. (role: recent adjacent dual-path behavior contributor; confidence: medium; commits: 2e20dd8dbf82; files: src/llm/providers/anthropic.ts, src/agents/anthropic-transport-stream.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jun 20, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Jun 20, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 20, 2026
@Pick-cat
Pick-cat force-pushed the fix/anthropic-oauth-user-agent-version branch from 3e07af8 to f03b439 Compare June 21, 2026 07:43
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 21, 2026
@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@Pick-cat
Pick-cat force-pushed the fix/anthropic-oauth-user-agent-version branch 3 times, most recently from c9cc22f to 6aa5b6b Compare June 23, 2026 10:54
@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated: rebased on latest main, fresh Evidence section with negative control proof (stale → fixed ), vitest 3 files / 120 tests passed, CI green.

@clawsweeper

clawsweeper Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated: rebased on latest main, fresh Evidence section with negative control proof (stale claude-cli/2.1.75 -> fixed claude-cli/2.1.177), vitest 3 files / 120 tests passed, CI green.

@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated PR body with all 4 required sections (Why This Change Was Made + User Impact added). Proof unchanged — negative control + production tsx harness + vitest 120/120.

@Pick-cat
Pick-cat force-pushed the fix/anthropic-oauth-user-agent-version branch from 6aa5b6b to 8efa69d Compare June 24, 2026 15:24
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Jun 24, 2026
@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed the two contributor-controllable P1s and narrowed the PR (now +90/−7, was +233):

  • Freshness P1: bumped the advertised version 2.1.177 → 2.1.187 (current npm latest of @anthropic-ai/claude-code).
  • Env-surface P1: removed OPENCLAW_CLAUDE_CODE_VERSION and its docs entirely — no new operator/auth-provider knob. The fix is now just collapsing the two drifting claude-cli/2.1.75 constants into one buildClaudeCliUserAgent() helper (your maintainer option 2).
  • Removed the stubbed fake-token proof script the review flagged; the "Real behavior proof" CI gate checks PR-body evidence, which remains.

On the real-OAuth proof P1: stated honestly in the body — a fully authenticated before/after needs a live Claude subscription token I can't include. Root cause is reproduced/documented in #94716; this is a self-evidently-correct non-stale-version repair with unit coverage and green CI, flagged for the maintainer proof-bar decision.

Validation on head 8efa69da07a: 117 touched/sibling tests green, tsgo:core + oxlint + check:docs clean, rebased on latest origin/main.

@clawsweeper

clawsweeper Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 24, 2026
@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the PR body (not just this comment) with fresh proof on head 28bd96aee013:

  • refreshed the advertised Claude Code version to current npm latest 2.1.191;
  • added production-path before/after proof showing origin/main stale claude-cli/2.1.75 vs PR head buildClaudeCliUserAgent() returning claude-cli/2.1.191;
  • kept both OAuth call sites covered: legacy provider and managed transport both use the shared helper;
  • reran targeted tests: 40 provider tests + 77 agents transport tests passed;
  • stated the remaining live Anthropic OAuth limitation honestly in the PR body because no usable OpenClaw Anthropic OAuth auth-profile is available on this machine and no token was extracted or printed.

@clawsweeper

clawsweeper Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@Pick-cat
Pick-cat force-pushed the fix/anthropic-oauth-user-agent-version branch from 28bd96a to cca9f19 Compare June 29, 2026 15:15
@openclaw-barnacle openclaw-barnacle Bot added channel: mattermost Channel integration: mattermost and removed docs Improvements or additions to documentation agents Agent runtime and tooling labels Jun 29, 2026
@Pick-cat Pick-cat changed the title fix(anthropic): send current claude-cli user-agent on OAuth path fix(mattermost): bound null-body error response reads Jun 29, 2026
@Pick-cat Pick-cat closed this Jun 29, 2026
@Pick-cat
Pick-cat deleted the fix/anthropic-oauth-user-agent-version branch June 29, 2026 15:17
@Pick-cat
Pick-cat restored the fix/anthropic-oauth-user-agent-version branch June 29, 2026 15:17
@Pick-cat Pick-cat reopened this Jun 29, 2026
@Pick-cat Pick-cat closed this Jun 29, 2026
@Pick-cat
Pick-cat deleted the fix/anthropic-oauth-user-agent-version branch June 29, 2026 15:22
@Pick-cat
Pick-cat restored the fix/anthropic-oauth-user-agent-version branch June 29, 2026 15:22
@Pick-cat Pick-cat reopened this Jun 29, 2026
@Pick-cat Pick-cat closed this Jun 29, 2026
@Pick-cat
Pick-cat deleted the fix/anthropic-oauth-user-agent-version branch June 29, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: mattermost Channel integration: mattermost merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P1 High-priority user-facing bug, regression, or broken workflow. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant