fix(web): build absolute cover_image URL on same-origin deployments (error toast on successful cover save) - #9783
Conversation
…on cover save (PLANE-15) PATCH /api/users/me/ rejects relative cover_image paths with 400 "Enter a valid URL." because the field is a Django URLField. The v2 user-asset upload already persists the cover server-side (auto-link in UserAssetsV2Endpoint.patch), so the profile PATCH failure surfaced as "There was some error in updating your profile" even though the cover was saved - matching upstream makeplane#9283. getFileURL() only prepends API_BASE_URL, which is empty on same-origin self-hosted builds, so it returned the relative path unchanged. Fall back to window.location.origin to build a fully-qualified URL. Also applies to project covers, which share handleCoverImageChange.
◈ PR Lens
Architecture 1 component touched across 2 lanes. Data flow
Drill down
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
Fixes #9283: saving a profile (or project) cover image shows an error toast even though the cover was actually saved.
Root cause: on same-origin self-hosted deployments
API_BASE_URLis empty, sogetFileURL()returns the asset path as a relative URL (/api/assets/v2/static/<id>/). The follow-upPATCH /api/users/me/then fails validation (cover_imageis a DjangoURLField→ 400 "Enter a valid URL."), which surfaces as the error toast — while the cover was already linked server-side viacover_image_asset_id, so the image appears saved after a reload.Fix: new
toAbsoluteCoverURL()incover-image.helper.tsbuilds an absolute URL fromAPI_BASE_URL || window.location.originwhen given a relative path; bothcover_imageassignments inhandleCoverImageChangeuse it. Project covers share this helper and are fixed too.Type of Change
Test Scenarios
PATCH /api/users/me/with relativecover_image→ 400; with the absolute URL produced by the fix → 200.check:types/check:lintfor web pass.References