Skip to content

fix(microsoft-foundry): keep Azure CLI error truncation UTF-16 safe#102604

Merged
steipete merged 3 commits into
openclaw:mainfrom
Pandah97:fix/cli-truncate-utf16
Jul 9, 2026
Merged

fix(microsoft-foundry): keep Azure CLI error truncation UTF-16 safe#102604
steipete merged 3 commits into
openclaw:mainfrom
Pandah97:fix/cli-truncate-utf16

Conversation

@Pandah97

@Pandah97 Pandah97 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Microsoft Foundry surfaces unexpected Azure CLI stderr/stdout in a bounded authentication error. The fallback path used raw .slice(0, 300), so supplementary Unicode crossing that UTF-16 boundary could leave a dangling surrogate in the operator-facing error.

Why This Change Was Made

The Foundry-owned error summarizer now uses the existing plugin-SDK truncateUtf16Safe helper at the same 300-code-unit limit. Existing classifications for missing Azure CLI, login, subscription, tenant, and AADSTS errors remain unchanged.

The regression test drives the public async token command path with a mocked execFile failure and asserts the complete propagated Error.message at the exact emoji boundary.

User Impact

Unexpected Azure CLI authentication details remain valid and readable when they contain supplementary Unicode. Command execution, timeout, classification, auth flow, and configuration are unchanged.

Evidence

  • node ../../node_modules/vitest/vitest.mjs run --config test/vitest/vitest.extension-providers.config.ts extensions/microsoft-foundry/index.test.ts — 92 tests passed.
  • Focused oxlint and git diff --check passed for the touched files.
  • The regression assertion covers the production getAccessTokenResultAsyncexecAzAsyncbuildAzCommandError path, not the helper in isolation.

No live Azure request is needed for this local child-process error-formatting boundary; the Azure API and successful CLI paths are unchanged.

AI-assisted

This PR was generated with Claude Code and improved/reviewed with Codex.

Replace `.slice(0, 300)` with `truncateUtf16Safe(normalized, 300)` in
summarizeAzErrorMessage to prevent surrogate pair corruption.

Ref. lsr911 pattern — mechanical substitution, no behavior change.
@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 6:43 AM ET / 10:43 UTC.

Summary
The branch replaces Microsoft Foundry’s fallback Azure CLI error slice(0, 300) with truncateUtf16Safe(..., 300) and adds a mocked regression test for the async token path.

PR surface: Source +1, Tests +16. Total +17 across 2 files.

Reproducibility: yes. from source inspection: current main uses slice(0, 300) after normalizing Azure CLI output, and the PR’s mocked async-token test demonstrates the boundary path. I did not run a live Azure CLI failure path in a user setup.

Review metrics: none identified.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

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

Rank-up moves:

  • [P2] Add redacted terminal output, copied live output, logs, or a terminal screenshot showing the changed Azure CLI fallback error path after the patch; redact private endpoints, tokens, IP addresses, and other sensitive details.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body provides mocked test/CI evidence only; add redacted terminal/live output, logs, or a terminal screenshot for the Azure CLI fallback error path, then update the PR body to trigger re-review or ask for @clawsweeper re-review.

Risk before merge

  • [P2] Real behavior proof is still mock-only; reviewers have not seen the patched Azure CLI fallback error path in redacted terminal output, copied live output, logs, or a terminal screenshot.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow helper substitution after the PR gains redacted real behavior proof for the Azure CLI fallback error path, or after a maintainer explicitly overrides that proof gate for this mechanical formatting fix.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No repair job is useful because the code change is already present; the remaining blocker is real behavior proof or maintainer proof override.

Maintainer decision needed

  • Question: Should this PR require redacted terminal/live proof of the Azure CLI fallback error path, or should a maintainer override the proof gate for this mechanical UTF-16 truncation fix?
  • Rationale: The code path and mocked regression test are clear, but ClawSweeper’s external-PR proof gate requires real behavior proof unless a maintainer accepts an override.
  • Likely owner: steipete — Recent main-history work and branch commits show the most direct current involvement with this Microsoft Foundry CLI/test path.
  • Options:
    • Require real terminal proof (recommended): Ask for redacted terminal output, copied live output, logs, or a terminal screenshot showing the patched Azure CLI fallback error path before merge.
    • Override proof for this PR: A maintainer may accept the mocked regression coverage as sufficient because the diff only swaps to an existing truncation helper at the same cap.

Security
Cleared: Cleared: the diff adds no dependency, script, permission, credential, network, package-resolution, or secret-handling change and only imports an existing SDK utility.

Review details

Best possible solution:

Land the narrow helper substitution after the PR gains redacted real behavior proof for the Azure CLI fallback error path, or after a maintainer explicitly overrides that proof gate for this mechanical formatting fix.

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

Yes, from source inspection: current main uses slice(0, 300) after normalizing Azure CLI output, and the PR’s mocked async-token test demonstrates the boundary path. I did not run a live Azure CLI failure path in a user setup.

Is this the best way to solve the issue?

Yes; using the existing plugin-SDK truncateUtf16Safe helper at the existing cap is the narrowest maintainable fix and matches the extension boundary. A local helper or broader CLI rewrite would add unnecessary surface.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P3: This is a low-blast-radius Unicode correctness fix for one provider’s displayed Azure CLI error message.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides mocked test/CI evidence only; add redacted terminal/live output, logs, or a terminal screenshot for the Azure CLI fallback error path, then update the PR body to trigger re-review or ask for @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +1, Tests +16. Total +17 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 16 0 +16
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 18 1 +17

What I checked:

Likely related people:

  • haxudev: The merged Microsoft Foundry provider PR added extensions/microsoft-foundry/cli.ts and the original summarizeAzErrorMessage fallback truncation. (role: feature introducer; confidence: high; commits: a16dd967da51; files: extensions/microsoft-foundry/cli.ts, extensions/microsoft-foundry/index.test.ts)
  • steipete: Recent main-history commits refactored Microsoft Foundry CLI output handling, and the latest PR commits add the focused regression test on this branch. (role: recent area contributor; confidence: high; commits: b52f10653318, 22955fcdcb5f, 9b4ae26942b2; files: extensions/microsoft-foundry/cli.ts, extensions/microsoft-foundry/index.test.ts)
  • lsr911: A recently merged sibling PR applied the same UTF-16-safe truncation helper pattern to another raw-slice site, making this useful context for the pattern rather than Foundry ownership. (role: adjacent UTF-16 truncation contributor; confidence: medium; commits: 49a5b6a23575; files: src/auto-reply/reply/post-compaction-context.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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-09T09:37:19.772Z sha 95845cf :: needs real behavior proof before merge. :: none

@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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 9, 2026
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Land-ready proof for exact head de8183e9528bb7df22067f148058cdec4d12a4ed:

  • Reviewed the Microsoft Foundry Azure CLI path from execFile output through error classification and operator-facing fallback text; known Azure CLI errors retain their canonical messages, while only the unknown-error preview is truncated.
  • Added a public-path regression through getAccessTokenResultAsync that asserts the complete emoji-boundary error message, rather than a substring-only matcher.
  • Focused Microsoft Foundry tests pass (92 tests). oxfmt, focused oxlint, git diff --check, and a fresh branch autoreview pass clean with no actionable findings.
  • Native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 102604 accepted exact-head hosted CI/Testbox.

No live Azure login is needed because command execution, authentication, and error classification are unchanged; this is isolated fallback-message formatting. No changelog entry or known proof gaps.

@steipete
steipete merged commit c335ecd into openclaw:main Jul 9, 2026
97 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
…penclaw#102604)

* fix(microsoft-foundry): keep Azure CLI error truncation UTF-16 safe

Replace `.slice(0, 300)` with `truncateUtf16Safe(normalized, 300)` in
summarizeAzErrorMessage to prevent surrogate pair corruption.

Ref. lsr911 pattern — mechanical substitution, no behavior change.

* test(microsoft-foundry): cover UTF-16-safe CLI errors

* test(microsoft-foundry): assert complete CLI error

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS 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.

2 participants