MCP - update_artist_socials#53
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
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 You can disable this status message by setting the ✨ 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 |
There was a problem hiding this comment.
Additional Suggestion:
The return type annotation declares Promise<Tables<"socials">[] | null> but the implementation always returns an array (never null), creating a type inconsistency that could mislead callers.
View Details
📝 Patch Details
diff --git a/lib/supabase/socials/selectSocials.ts b/lib/supabase/socials/selectSocials.ts
index ee04075..efa001a 100644
--- a/lib/supabase/socials/selectSocials.ts
+++ b/lib/supabase/socials/selectSocials.ts
@@ -15,7 +15,7 @@ type SelectSocialsParams = {
*/
export async function selectSocials(
params: SelectSocialsParams,
-): Promise<Tables<"socials">[] | null> {
+): Promise<Tables<"socials">[]> {
let query = supabase.from("socials").select("*").order("updated_at", { ascending: false });
if (params.id) {
Analysis
Type annotation mismatch in selectSocials() - function always returns array, never null
What fails: selectSocials() in lib/supabase/socials/selectSocials.ts declares return type Promise<Tables<"socials">[] | null> but the implementation always returns an array, never null.
How to reproduce:
// The type contract says the function might return null:
const result: Promise<Tables<"socials">[] | null> = selectSocials({ ... });
// But looking at the implementation:
return data || []; // Always returns an array, never nullResult: TypeScript type checker allows code to assume the function might return null. However, Supabase's select() method returns { data: [], error: null } (not { data: null, error: null }) when there are no matching results. After the error check, data is never null, so data || [] always returns an array.
Expected: According to Supabase documentation, the select query returns an empty array when no rows match, not null. Therefore, the return type should be Promise<Tables<"socials">[]>, not Promise<Tables<"socials">[] | null>.
Impact: The misleading type annotation causes callers to defensively check for null (e.g., socials?.[0] in lib/socials/postSocialScrapeHandler.ts), which is unnecessary defensive programming and obscures the actual contract.
No description provided.