Skip to content

fix(bio-editor): correct image upload and hosted/external classification - #23

Merged
SiteRelEnby merged 1 commit into
mainfrom
fix/bio-editor-image-handling
Jul 11, 2026
Merged

SiteRelEnby merged 1 commit into
mainfrom
fix/bio-editor-image-handling

Conversation

@SiteRelEnby

Copy link
Copy Markdown
Collaborator

Fixes #21.

Two bugs in the markdown bio/description editor's image handling.

1. Uploading an image silently failed

  • The upload posted with the endpoint's default purpose (avatar) instead of bio, so bio images were tagged wrong and bypassed the bio-images gate. Now uploads pass purpose=bio, matching web (uploadFile(file, "bio")).
  • The delegate set an error in its state on failure, but nothing in the UI ever read it - so a rejected upload just disappeared with no feedback. The editor now surfaces the failure reason under the field.

Between these, a failed upload is now visible and diagnosable instead of silent, and successful uploads are tagged correctly.

2. Hosted images were labelled "external"

Two causes:

  • Uploaded images embedded the absolute response URL instead of the canonical /v1/files/<key> path. Web (and the app's own "Existing image" picker) embed the path form; the backend rewrites it to the real signed/CDN URL on read.
  • isHostedImageUrl only matched /v1/files/. On the hosted instance, files resolve to a CDN (s3_public_url) whose URLs contain no /v1/files/, so every hosted image was classified external.

Now uploads embed /v1/files/<key>, and isHostedImageUrl also matches the instance's file CDN base - mirroring web's isHostedImage(src, cdnBase). The CDN base (file_cdn_base from the auth config, already persisted in prefs) is provided app-wide via a LocalFileCdnBase composition local, so both the bio editor and the journals image panel classify correctly without threading it through every caller.

Tests

  • New ImageSourceClassificationTest: /v1/files/ (relative, signed, absolute-through-API), CDN-base matching, trailing-slash handling, and host-boundary safety (a cdn.example.com.evil.net lookalike stays external).
  • :app:testPlayReleaseUnitTest and :app:assemblePlayRelease green.

Notes

  • The exact server-side rejection that caused the original silent failure wasn't reproducible from here, but it's now surfaced to the user, so whatever the instance returns (uploads disabled, too large, bad format) is visible.
  • Not device-tested here; worth a manual pass: upload an image in a bio, confirm it embeds and shows "hosted", and confirm a rejected upload shows an error.

Two bugs in the markdown bio/description editor's image handling (#21):

1. Uploads silently failed. The upload posted with the default purpose
   ("avatar") instead of "bio", and the delegate set an error that no UI
   ever read, so a rejected upload just vanished. Now it uploads with
   purpose=bio (matching web) and the editor surfaces the failure reason.

2. Hosted images showed as "external". Two causes: uploaded images embedded
   the absolute response URL instead of the canonical /v1/files/<key> path,
   and the classifier only matched /v1/files/, missing CDN-served URLs. On
   the hosted instance files resolve to the CDN (no /v1/files/ in the URL),
   so they were all flagged external. Uploads now embed the canonical path
   (the backend rewrites it to the real URL on read), and isHostedImageUrl
   also matches the instance's file CDN base, mirroring web's
   isHostedImage(src, cdnBase). The CDN base is provided app-wide via a
   LocalFileCdnBase composition local sourced from the auth config.

Adds unit tests for the classification, covering /v1/files/, CDN-base
matching, and host-boundary safety.
@SiteRelEnby
SiteRelEnby enabled auto-merge July 11, 2026 03:26
@SiteRelEnby
SiteRelEnby merged commit 42e5a56 into main Jul 11, 2026
1 check passed
@SiteRelEnby
SiteRelEnby deleted the fix/bio-editor-image-handling branch July 11, 2026 03:30
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.

Bio editor image bugs

1 participant