Skip to content

fix(ui): allow relative URLs in avatar validation - #1457

Merged
steipete merged 2 commits into
openclaw:mainfrom
dlauer:fix/avatar-relative-url-validation
Jan 22, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
dlauer:fix/avatar-relative-url-validation

Conversation

@dlauer

@dlauer dlauer commented Jan 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Local file avatars configured in identity.avatar display as text instead of images in the webchat UI.

Root Cause (3-layer bug)

1. Frontend - URL validation too strict

isAvatarUrl() only accepted http://, https://, or data: URLs:

// Before: didn't accept relative paths
/^https?:\/\//i.test(value) || /^data:image\//i.test(value)

2. Backend HTML injection

serveIndexHtml() injected the raw avatar filename into HTML instead of the resolved URL.

3. Backend RPC

agent.identity.get returned the raw filename, which overwrote the HTML-injected value when the frontend fetched identity.

Fix

  1. Frontend: Accept relative paths starting with /
  2. Backend (control-ui.ts): Resolve local file avatars to /avatar/{agentId} URL before injection
  3. Backend (agent.ts): Resolve local file avatars in RPC response

Testing

  • Configure identity.avatar: "myavatar.png" in agent config
  • Place image in workspace
  • Avatar now displays correctly in webchat

Regression from #1329 refactor in 8544df3.

The isAvatarUrl check only accepted http://, https://, or data: URLs,
but the /avatar/{agentId} endpoint returns relative paths like /avatar/main.
This caused local file avatars to display as text instead of images.

Fixes avatar display for locally configured avatar files.
The frontend fix alone wasn't enough because:
1. serveIndexHtml() was injecting the raw avatar filename into HTML
2. agent.identity.get RPC was returning raw filename, overwriting the
   HTML-injected value

Now both paths resolve local file avatars (*.png, *.jpg, etc.) to the
/avatar/{agentId} endpoint URL.
@steipete

Copy link
Copy Markdown
Contributor
  • High: agent.identity.get rewrites to /avatar/${agentId} without controlUiBasePath; when base path is set, avatar endpoint is ${basePath}/avatar/..., so the RPC refresh will 404 and overwrite the injected URL. src/gateway/server-methods/agent.ts:407, src/ gateway/control-ui.ts:101, src/gateway/control-ui.ts:119
  • Medium: looksLikeLocalAvatarPath only keys off extensions; values like avatars/profile (accepted by looksLikeAvatarPath) won’t be converted and will still render as text. src/gateway/control-ui.ts:206, src/gateway/assistant-identity.ts:33

@steipete steipete self-assigned this Jan 22, 2026
@steipete
steipete merged commit 6c7f224 into openclaw:main Jan 22, 2026
@steipete

Copy link
Copy Markdown
Contributor

Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test\n- Land commit: 482fcd2\n- Merge commit: 6c7f224\n\nThanks @dlauer!

dustin-olenslager pushed a commit to dustin-olenslager/ironclaw-supreme that referenced this pull request Mar 24, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…validation

fix(ui): allow relative URLs in avatar validation
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…validation

fix(ui): allow relative URLs in avatar validation
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…validation

fix(ui): allow relative URLs in avatar validation
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
@clawsweeper clawsweeper Bot mentioned this pull request May 16, 2026
4 of 15 tasks
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
zeekay pushed a commit to Dream-AI-4444/moltbot that referenced this pull request Sep 11, 2026
…validation

fix(ui): allow relative URLs in avatar validation
zeekay pushed a commit to Dream-AI-4444/bot that referenced this pull request Sep 11, 2026
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
…validation

fix(ui): allow relative URLs in avatar validation
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants