refactor(web): guard RightRail attachment payload instead of casting#73
Conversation
The attachments rail branch cast each payload item straight to AttachmentView (`item as AttachmentView`) with no runtime check, so a malformed payload would flow garbage into AttachmentActions. Filter the array through an isAttachmentView guard so only well-formed attachments render. (The sender-profile and commitments panels already validate their payloads internally via extractSenderProfile / extractCommitments, so they are not a crash risk despite taking `unknown`.)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 56 minutes and 37 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
What
Replaces an unchecked
item as AttachmentViewcast inRightRail's attachments branch with a runtimeisAttachmentViewtype guard. Audit backlog item P2 #21 (RightRail type-safety).Why
The attachments rail mapped each payload item with a bare cast, so a malformed payload would flow garbage into
AttachmentActions(e.g.attachment.id/filenameundefined). The other rail kinds already guard their payloads; this brings the attachments branch in line.Scope notes (honest verification)
unknown"without type guards." On inspection they do validate internally —extractSenderProfilereturnsnullandextractCommitmentsreturns[]on a bad shape, each rendering an empty state — so they are not a crash risk and are left as-is.Verification
npm run typecheck,oxlint,oxfmt --checkclean;vite buildsucceeds.Generated with Claude Code
Summary by cubic
Guard attachment payloads in
RightRailwith a runtimeisAttachmentViewcheck, replacing the unchecked cast. Prevents malformed items from reachingAttachmentActionsand aligns with other rails; addresses audit item P2 #21.isAttachmentViewand filter the attachments array before rendering, so only well-formed attachments render.Written for commit 21ce202. Summary will update on new commits.