fix(marketplace): report comment load failures#371
Conversation
Greptile SummaryThis PR fixes all four marketplace comment components (
Confidence Score: 5/5This PR is safe to merge — all four changes are structurally identical, logically correct, and directly verified by the new test suite. The fetchComments refactor is mechanically consistent across all four components: the finally block guarantees setLoading(false) fires on every exit path (early return, normal completion, and thrown exception), the .catch(() => ({})) fallback correctly handles non-JSON error bodies, and the error ? null : guard in the render path reliably prevents the misleading empty-state message. The new table-driven test directly exercises the 503 path for every surface and asserts both the alert content and the absence of the empty-state text. No logic changes were made to the happy path or to handlePost. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant C as Component (mount)
participant F as fetchComments()
participant API as /api/.../comments
C->>F: useEffect triggers fetchComments()
F->>API: GET request
alt HTTP 2xx (ok)
API-->>F: "200 OK + {comments, total}"
F->>C: setComments(), setTotal()
F->>C: finally: setLoading(false)
C->>C: render comment list (or empty state)
else HTTP error (non-ok)
API-->>F: "4xx/5xx + {error: ...}"
F->>C: "setError(data.error || "Failed to load comments")"
F->>F: return (exits try block)
F->>C: finally: setLoading(false)
C->>C: "render role=alert error banner, suppress empty-state"
else Network failure
API-->>F: throws (network error)
F->>C: catch: setError("Failed to load comments")
F->>C: finally: setLoading(false)
C->>C: "render role=alert error banner, suppress empty-state"
end
Reviews (1): Last reviewed commit: "fix(marketplace): report comment load fa..." | Re-trigger Greptile |
Summary
Paid task
https://ugig.net/gigs/abd6b2a0-e728-48cf-a46f-f99e419ed94e
Verification
pnpm exec vitest run src/components/MarketplaceComments.test.tsxpnpm exec eslint src/components/directory/DirectoryComments.tsx src/components/mcp/McpComments.tsx src/components/prompts/PromptComments.tsx src/components/skills/SkillComments.tsx src/components/MarketplaceComments.test.tsxgit diff --check