fix: handle both array and object response shapes for single-asset share comments#71
Closed
xxiaoxiong wants to merge 1 commit into
Closed
Conversation
…are comments The API returns a bare array for single-asset shares but an object with a 'comments' property for folder shares. This caused comments to never render on single-asset public share links. Updated GuestCommentList to detect and handle both response formats: - Array.isArray(data) ? data : data.comments ?? [] This preserves compatibility with folder shares while fixing the single-asset share comment display issue. Fixes #67
Contributor
|
Thanks for picking this up @xxiaoxiong! 🙏 We landed essentially the same fix in #70 just before this PR came in — sorry for the duplicated effort, the timing was unfortunate. Both PRs took the same approach (frontend handles both response shapes via If you'd like to take another swing at it, the proper long-term fix is tracked in #72: normalize the backend so Closing this one as superseded by #70. Thanks again for the contribution! |
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
Reported in #67 by @ducknoodledance.
When opening a public single-asset share link, the comments panel is always empty even when comments exist. Project/folder shares work correctly.
Root Cause
Response shape mismatch between API and frontend:
API (
apps/api/routers/comments.py:567) returns a bare array:Frontend (
apps/web/app/share/[token]/page.tsx:204) expected an object:Since
data.commentsisundefinedon an array, it silently falls back to[].The folder-share viewer uses a different code path that handles the array correctly, which is why project shares work.
Solution
Updated
GuestCommentListto handle both response formats:This approach:
Testing
Tested with:
Closes #67