openclaw - ✅(Solved) Fix Bug: current-run HEIC prompt images reach OpenAI as image/heic instead of being normalized before model send [1 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#50081Fetched 2026-04-08 00:59:19
View on GitHub
Comments
1
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
commented ×1cross-referenced ×1

HEIC/HEIF images uploaded in the OpenClaw Control UI can fail on the current run with OpenAI vision models even though the persisted message is later normalized to JPEG successfully.

The user-visible error is:

The image data you provided does not represent a valid image. Please check your input and try again with one of the supported image formats: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].

Error Message

The user-visible error is: 4. Observe that the run can fail with the invalid-image error above. and the invalid-image error disappeared.

Root Cause

The failing path is the prompt-image handoff used for the current run.

During debugging, we confirmed:

  • before_prompt_build saw the persisted user message image as image/jpeg
  • but the current run's promptImages handoff still contained raw image/heic
  • OpenAI then rejected that current-run image payload

In other words, HEIC normalization was happening after persistence, but not early enough for the immediate activeSession.prompt(..., { images }) call.

Fix Action

Fix / Workaround

After hot-patching the prompt-image handoff to normalize HEIC/HEIF to JPEG before the model call, the same workflow produced:

PR fix notes

PR #50320: Fix priority regressions in export attachments auth and denyCommands

Description (problem / solution / changelog)

Summary

  • fix export session HTML token injection by supporting both plain and formatted script placeholders
  • normalize HEIC and HEIF chat attachments to JPEG before prompt image upload
  • treat google-vertex ADC sentinel as oauth mode and do not pass it as apiKey
  • add config set warnings for gateway.nodes.denyCommands unknown or pattern-like entries
  • add regression tests for all four fixes

Linked issues

  • closes #49957
  • closes #50081
  • closes #50053
  • closes #50011

Validation

  • pnpm test src/auto-reply/reply/export-html/template.security.test.ts src/gateway/chat-attachments.test.ts src/agents/model-auth.test.ts src/cli/config-cli.test.ts
  • pnpm check and pnpm tsgo still report existing unrelated repo-wide TypeScript errors

Changed files

  • src/agents/model-auth.test.ts (modified, +32/-0)
  • src/agents/model-auth.ts (modified, +20/-0)
  • src/auto-reply/reply/commands-export-session.ts (modified, +22/-6)
  • src/auto-reply/reply/export-html/template.security.test.ts (modified, +10/-1)
  • src/cli/config-cli.test.ts (modified, +49/-0)
  • src/cli/config-cli.ts (modified, +152/-0)
  • src/gateway/chat-attachments.test.ts (modified, +46/-0)
  • src/gateway/chat-attachments.ts (modified, +35/-2)
RAW_BUFFERClick to expand / collapse

Summary

HEIC/HEIF images uploaded in the OpenClaw Control UI can fail on the current run with OpenAI vision models even though the persisted message is later normalized to JPEG successfully.

The user-visible error is:

The image data you provided does not represent a valid image. Please check your input and try again with one of the supported image formats: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].

Environment

  • OpenClaw: observed on 2026.3.13-era install
  • Provider/model: openai-codex/gpt-5.4
  • Surface: OpenClaw Control UI / webchat
  • Host: macOS

Repro

  1. Open the OpenClaw Control UI (webchat).
  2. Upload a .heic / .heif image.
  3. Ask the agent to inspect/read the image.
  4. Observe that the run can fail with the invalid-image error above.

PNG uploads in the same environment succeed.

What makes this subtle

The persisted user message may already look fixed later:

  • the inbound/persistence path can normalize the saved image to JPEG
  • history sanitization logs may show successful JPEG conversion/resizing

But the current-run prompt image can still be handed to the model as raw image/heic, which is too late for the model call that is already in flight.

Root cause

The failing path is the prompt-image handoff used for the current run.

During debugging, we confirmed:

  • before_prompt_build saw the persisted user message image as image/jpeg
  • but the current run's promptImages handoff still contained raw image/heic
  • OpenAI then rejected that current-run image payload

In other words, HEIC normalization was happening after persistence, but not early enough for the immediate activeSession.prompt(..., { images }) call.

Confirmation / evidence

Instrumentation showed a failing handoff like:

  • prompt image handoff ... mime=image/heic ... head=AAAAKGZ0eXBoZWlj...

That run then failed with:

  • The image data you provided does not represent a valid image...

After hot-patching the prompt-image handoff to normalize HEIC/HEIF to JPEG before the model call, the same workflow produced:

  • prompt image handoff ... mime=image/jpeg ... head=/9j/...

and the invalid-image error disappeared.

Fix direction

Normalize HEIC/HEIF prompt images to JPEG before calling the model for the current run.

Specifically, the prompt-image path used by activeSession.prompt(..., { images }) should apply the same HEIC normalization used elsewhere, rather than only relying on later persistence/history normalization.

Notes

This appears distinct from:

  • old iMessage attachment ingestion bugs
  • the Control UI bug where images visually disappear after assistant responses

Those may coexist, but this issue is specifically about the current-run prompt image payload still being image/heic when handed to the provider.

extent analysis

Fix Plan

To fix the issue, we need to normalize HEIC/HEIF images to JPEG before calling the model for the current run. Here are the steps:

  • Modify the activeSession.prompt() function to normalize the image payload before sending it to the model.
  • Use a library like sharp to convert HEIC/HEIF images to JPEG.
  • Update the promptImages handoff to use the normalized JPEG image.

Example code:

const sharp = require('sharp');

// ...

const normalizeImage = async (image) => {
  if (image.mime === 'image/heic' || image.mime === 'image/heif') {
    const buffer = await sharp(image.buffer)
      .jpeg()
      .toBuffer();
    return { ...image, buffer, mime: 'image/jpeg' };
  }
  return image;
};

// ...

const promptImages = await Promise.all(images.map(normalizeImage));
activeSession.prompt(..., { images: promptImages });

Verification

To verify that the fix worked, upload a HEIC/HEIF image in the OpenClaw Control UI and ask the agent to inspect/read the image. The run should no longer fail with the invalid-image error.

Extra Tips

  • Make sure to test the fix with different image formats and sizes to ensure that the normalization works correctly.
  • Consider adding error handling to the normalizeImage function to handle cases where the image conversion fails.
  • If you're using a cloud-based image processing service, make sure to check their documentation for any specific requirements or limitations on image format conversion.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING