Repository navigation
fix(bio-editor): correct image upload and hosted/external classification - #23
Merged
Merged
Conversation
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.
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.
Fixes #21.
Two bugs in the markdown bio/description editor's image handling.
1. Uploading an image silently failed
purpose(avatar) instead ofbio, so bio images were tagged wrong and bypassed the bio-images gate. Now uploads passpurpose=bio, matching web (uploadFile(file, "bio")).errorin 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:
/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.isHostedImageUrlonly 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>, andisHostedImageUrlalso matches the instance's file CDN base - mirroring web'sisHostedImage(src, cdnBase). The CDN base (file_cdn_basefrom the auth config, already persisted in prefs) is provided app-wide via aLocalFileCdnBasecomposition local, so both the bio editor and the journals image panel classify correctly without threading it through every caller.Tests
ImageSourceClassificationTest:/v1/files/(relative, signed, absolute-through-API), CDN-base matching, trailing-slash handling, and host-boundary safety (acdn.example.com.evil.netlookalike stays external).:app:testPlayReleaseUnitTestand:app:assemblePlayReleasegreen.Notes