refactor(maintainer): use unwrapJoin to safely parse github_installations relations#406
Conversation
|
@diksha78dev is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Implementation looks right, matches process-pr-event.ts's pattern. But this still doesn't have a test for the array-shape case - every existing test in detect.test.ts mocks github_installations as an object, so the fix is unverified against the actual bug it's for. Can you add one mocking it as [{ uninstalled_at: null }]? Also, isUserMaintainer uses as any while listMaintainerInstalls uses a typed unknown cast - worth matching styles.
|
@Ayush-Patel-56 I have added the requested changes and updated the |
jakharmonika364
left a comment
There was a problem hiding this comment.
Array-shape tests added for both functions, cast styles unified. LGTM
Summary
Replaces manual object casts of
github_installationsjoins indetect.tswith theunwrapJoinhelper. This ensures the relationship extraction is type-safe and resilient, preventing runtime errors if Supabase returns the inner join as an array instead of an object.Type of Change
Related Issue
Closes #390
What was changed?
unwrapJoinutility from@/lib/supabase/inner-join.isUserMaintainerto extract the relation payload securely usingunwrapJoin<{ uninstalled_at: string | null }>rather than enforcing strict object coercion.listMaintainerInstallsby typing the rawgithub_installationsproperty asunknownand implementing an initial map iteration to safely unwrap the data before executing the subsequent.filter()logic.Screenshots
N/A
Checklist
npm run dev)