fix(objectql): accept relative and inline URLs on url fields#3400
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 13 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Uploading a user avatar failed — the Console profile page showed
Auth request failed with status 500onPOST /api/v1/auth/update-user.Root cause: the Console avatar uploader (
createObjectStackUploadAdapter) PUTs the image to the platform storage service, then writessys_user.image(aField.url) = the storage service's root-relative download URL, e.g./api/v1/storage/files/<id>. The ObjectQL record-validator'surl-type check (URL_RE) required an absolutescheme://URL, so it rejected that value withinvalid_url→ the write failed (and, pre-#3399, surfaced as a raw 500).Fix
URL_REnow accepts, in addition toscheme://…:/path,//host/path) — the same-origin asset form the storage service returnsdata:andblob:inline formsA bare scheme-less string with no leading
/(e.g."notaurl") is still rejected.Relationship to #3399
Complementary, no file overlap:
ValidationErroron the better-auth paths to a clean400 { code: 'VALIDATION_FAILED', … }instead of an opaque 500 — better failure ergonomics.Verification
record-validator.test.ts: +6 cases (incl. the real avatar value/api/v1/storage/files/<id>), 40/40 green./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