Skip to content

fix(objectql): accept relative and inline URLs on url fields#3400

Merged
os-zhuang merged 1 commit into
mainfrom
claude/user-avatar-upload-error-d4c8e5
Jul 22, 2026
Merged

fix(objectql): accept relative and inline URLs on url fields#3400
os-zhuang merged 1 commit into
mainfrom
claude/user-avatar-upload-error-d4c8e5

Conversation

@baozhoutao

Copy link
Copy Markdown
Contributor

Problem

Uploading a user avatar failed — the Console profile page showed Auth request failed with status 500 on POST /api/v1/auth/update-user.

Root cause: the Console avatar uploader (createObjectStackUploadAdapter) PUTs the image to the platform storage service, then writes sys_user.image (a Field.url) = the storage service's root-relative download URL, e.g. /api/v1/storage/files/<id>. The ObjectQL record-validator's url-type check (URL_RE) required an absolute scheme:// URL, so it rejected that value with invalid_url → the write failed (and, pre-#3399, surfaced as a raw 500).

Fix

URL_RE now accepts, in addition to scheme://…:

  • root-/protocol-relative refs (/path, //host/path) — the same-origin asset form the storage service returns
  • data: and blob: inline forms

A bare scheme-less string with no leading / (e.g. "notaurl") is still rejected.

Relationship to #3399

Complementary, no file overlap:

Verification

  • record-validator.test.ts: +6 cases (incl. the real avatar value /api/v1/storage/files/<id>), 40/40 green.
  • End-to-end in the running Console (showcase dev): avatar upload → display → replace → remove all succeed; the stored /api/v1/storage/files/<id> resolves (302 → signed URL) to the real PNG bytes and renders in the profile card + top nav. No 500.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 22, 2026 1:47am

Request Review

@github-actions github-actions Bot added size/s documentation Improvements or additions to documentation tests tooling labels Jul 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/objectql.

13 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/concepts/metadata-lifecycle.mdx (via @objectstack/objectql)
  • content/docs/data-modeling/formulas.mdx (via packages/objectql)
  • content/docs/deployment/migration-from-objectql.mdx (via @objectstack/objectql)
  • content/docs/deployment/vercel.mdx (via @objectstack/objectql)
  • content/docs/kernel/services-checklist.mdx (via @objectstack/objectql)
  • content/docs/kernel/services.mdx (via @objectstack/objectql)
  • content/docs/permissions/authentication.mdx (via @objectstack/objectql)
  • content/docs/plugins/index.mdx (via @objectstack/objectql)
  • content/docs/plugins/packages.mdx (via @objectstack/objectql)
  • content/docs/protocol/kernel/index.mdx (via @objectstack/objectql)
  • content/docs/protocol/objectql/state-machine.mdx (via @objectstack/objectql)
  • content/docs/releases/implementation-status.mdx (via @objectstack/objectql)
  • content/docs/releases/v9.mdx (via @objectstack/objectql)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

The record-validator's url-type check required an absolute `scheme://`
URL, so it rejected the root-relative value the platform's own storage
service returns for an uploaded file. The console avatar uploader PUTs the
image to storage and then writes `sys_user.image` (a Field.url) =
`/api/v1/storage/files/<id>`; that failed `invalid_url` and, on the
better-auth `update-user` path, broke the avatar-upload profile save.

`URL_RE` now also accepts root-/protocol-relative refs (`/path`,
`//host/path`) and the `data:` / `blob:` inline forms, in addition to
`scheme://…`. A bare scheme-less string (e.g. "notaurl") is still rejected.

Verified end-to-end in the running Console: avatar upload → display →
replace → remove all succeed. Complements #3399 (which maps the validation
error to a clean 4xx); this makes the legitimate relative URL pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@os-zhuang
os-zhuang merged commit 54f479a into main Jul 22, 2026
16 checks passed
@os-zhuang
os-zhuang deleted the claude/user-avatar-upload-error-d4c8e5 branch July 22, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants