Skip to content

fix(openai): use truncateUtf16Safe for image gen log value truncation#102611

Merged
steipete merged 2 commits into
openclaw:mainfrom
lzyyzznl:fix/truncateUtf16Safe-openai-img
Jul 9, 2026
Merged

fix(openai): use truncateUtf16Safe for image gen log value truncation#102611
steipete merged 2 commits into
openclaw:mainfrom
lzyyzznl:fix/truncateUtf16Safe-openai-img

Conversation

@lzyyzznl

@lzyyzznl lzyyzznl commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The OpenAI image provider bounds model and auth-mode values before logging its Codex Responses auth-selection diagnostic. A raw UTF-16 code-unit slice could leave a dangling surrogate when an emoji crossed the existing 256-unit boundary.

Why This Change Was Made

Use the shared plugin-SDK truncateUtf16Safe primitive at the existing limit. The sanitization and logging owner remain unchanged, and the fix does not add a second code path or change Codex request/response behavior.

User Impact

Long OpenAI image-generation log values remain valid Unicode. ASCII behavior, the 256-unit bound, auth routing, and image-generation requests are unchanged.

Evidence

  • Added an exact public-provider-path regression with a surrogate pair crossing the 256-unit boundary.
  • Focused OpenAI provider suite: 67 passed.
  • Focused oxfmt, oxlint, and git diff --check passed.
  • Fresh autoreview clean (0.99).
  • Direct Codex source inspection confirmed image generation is a stable Responses API item and this patch only affects OpenClaw's local auth-selection log.

Generated with Claude Code; reviewed and improved by an OpenClaw maintainer agent.

One .slice(0, N) truncation site in the OpenAI image generation
provider may cut UTF-16 surrogate pairs in half when the log value
contains multi-byte characters such as emoji. Replace it with
truncateUtf16Safe to keep the truncated output valid Unicode.
@openclaw-barnacle openclaw-barnacle Bot added extensions: openai size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 9, 2026
@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:36 AM ET / 10:36 UTC.

Summary
The PR replaces the OpenAI image-generation log sanitizer's raw slice truncation with the shared UTF-16-safe truncation helper.

PR surface: Source +1. Total +1 across 1 file.

Reproducibility: yes. by source inspection: current main truncates OpenAI image auth/model log values with a raw UTF-16 code-unit slice, which can split a surrogate pair at the limit. I did not run a live reproduction because this review is read-only.

Review metrics: none identified.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦞 diamond lobster
Result: blocked until 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 real behavior proof showing emoji-containing OpenAI image auth/model log values after the fix.
  • Update the PR body after adding proof so ClawSweeper can re-review the current head.

Proof guidance:

  • [P1] Needs real behavior proof before merge: No PR body or comment proof shows the after-fix OpenAI image-generation log path; add redacted terminal output, copied live output, logs, or a validation transcript, then update the PR body to trigger re-review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • [P1] No after-fix real behavior proof has been posted, so maintainers cannot yet verify the actual OpenAI image log truncation path in a real setup.

Maintainer options:

  1. Decide the mitigation before merge
    Merge after redacted terminal output, copied live output, logs, or a maintainer proof override confirms emoji-containing OpenAI image auth/model log values truncate without dangling surrogate halves.
  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 lane is appropriate because I found no concrete code defect in the patch; the remaining blocker is contributor-provided real behavior proof or a maintainer proof override.

Security
Cleared: The diff only imports and calls an existing internal text truncation helper; no security or supply-chain concern was found.

Review details

Best possible solution:

Merge after redacted terminal output, copied live output, logs, or a maintainer proof override confirms emoji-containing OpenAI image auth/model log values truncate without dangling surrogate halves.

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

Yes, by source inspection: current main truncates OpenAI image auth/model log values with a raw UTF-16 code-unit slice, which can split a surrogate pair at the limit. I did not run a live reproduction because this review is read-only.

Is this the best way to solve the issue?

Yes for the code shape: reusing the exported truncateUtf16Safe helper at the owner-local sanitizer is the narrow maintainable fix. Merge readiness still depends on real behavior proof or a maintainer proof override.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P3: This is a small provider log-string correctness fix with limited blast radius and no config, protocol, persistence, availability, or security surface change.
  • 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 real behavior proof before merge: No PR body or comment proof shows the after-fix OpenAI image-generation log path; add redacted terminal output, copied live output, logs, or a validation transcript, then update the PR body to trigger re-review or ask a maintainer for @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +1. Total +1 across 1 file.

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

What I checked:

Likely related people:

  • obviyus: Current blame on main attributes the OpenAI image-generation sanitizer and the shared UTF-16 helper surface to commit 4cbe49b, which GitHub associates with fix(agents): run-lifecycle reliability — bounded release, evidence-based liveness, watchdog semantics #102160 by this user. (role: recent area contributor; confidence: medium; commits: 4cbe49ba881a; files: extensions/openai/image-generation-provider.ts, packages/normalization-core/src/utf16-slice.ts, src/plugin-sdk/text-utility-runtime.ts)
  • vincentkoc: History shows commit 0f54ca2 moved the OpenAI image-generation provider into the bundled plugin boundary, and commit e085fa1 also carried the same OpenAI image provider and text utility surfaces. (role: feature-history contributor; confidence: medium; commits: 0f54ca20aa50, e085fa1a3ffd; files: extensions/openai/image-generation-provider.ts, src/plugin-sdk/text-utility-runtime.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:39:15.895Z sha 5a85116 :: needs real behavior proof before merge. :: none

@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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 9, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 9, 2026
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Land-ready review complete on exact head a8afb73557031d44c21c42efcf6512b7645f3369.

  • Replaced the raw 256-unit OpenAI image auth-log cut with the shared plugin-SDK UTF-16-safe truncator while preserving the existing sanitization and ellipsis.
  • Added an exact public-provider-path regression with an emoji crossing the boundary.
  • Focused OpenAI provider suite: 67 passed.
  • Static proof: focused oxfmt, oxlint, git diff --check; fresh autoreview clean (0.99).
  • Direct Codex contract proof: codex-rs/protocol/src/models.rs defines the Responses API ImageGenerationCall; codex-rs/app-server-protocol/src/protocol/v2/item.rs maps it to the stable app-server image-generation item. This patch changes only OpenClaw's local auth-selection diagnostic.
  • Native prepare gate: exact-head hosted CI/Testbox passed with 62 relevant checks; remote PR head tree matches the prepared tree.

No docs or changelog entry is required because request routing and image-generation behavior are unchanged.

@steipete
steipete merged commit 6c3a46f into openclaw:main Jul 9, 2026
95 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
…openclaw#102611)

* fix(openai): use truncateUtf16Safe for image gen log value truncation

One .slice(0, N) truncation site in the OpenAI image generation
provider may cut UTF-16 surrogate pairs in half when the log value
contains multi-byte characters such as emoji. Replace it with
truncateUtf16Safe to keep the truncated output valid Unicode.

* fix(openai): keep image auth logs UTF-16 safe

---------

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

extensions: openai P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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