RPC function not found even though it exists on the actual Supabase UI
basicaly when i try to call an RPC function through this code:
this is the function wrapper(there are a lot of log statements cause i have been trying to debug this for a long time lol)
and this is the code where the actual function is being called:
I genuinely don't know what I am doing wrong this was working a few days ago.
this is the function wrapper(there are a lot of log statements cause i have been trying to debug this for a long time lol)
export const getAssignmentById = async (supabase: SupabaseClient, assignmentId: string) => {
try {
console.log('🚀 CALLING RPC FUNCTION:', 'get_assignment_by_id');
console.log('🚀 WITH PARAMETER:', { p_id: assignmentId });
console.log('🚀 ASSIGNMENT ID TYPE:', typeof assignmentId);
console.log('🚀 ASSIGNMENT ID VALUE:', assignmentId);
const result = await supabase.rpc("get_assignment_by_id", { p_id: assignmentId });
console.log('🔍 RAW RPC RESULT:', JSON.stringify(result, null, 2));
console.log('🔍 RESULT.ERROR:', result.error);
console.log('🔍 RESULT.DATA:', result.data);
if (result.data && Array.isArray(result.data)) {
console.log('🔍 FIRST ELEMENT:', result.data[0]);
}
if (result.error) {
console.error('❌ RPC Error in getAssignmentById:', result.error);
console.error('❌ ERROR CODE:', result.error.code);
console.error('❌ ERROR MESSAGE:', result.error.message);
console.error('❌ ERROR DETAILS:', result.error.details);
throw new Error(`RPC function failed: ${result.error.message}`);
}
return result;
} catch (error) {
console.error('💥 CATCH BLOCK - Error calling get_assignment_by_id:', error);
console.error('💥 ERROR TYPE:', typeof error);
if (error instanceof Error) {
console.error('💥 ERROR MESSAGE:', error.message);
}
throw error;
}
};export const getAssignmentById = async (supabase: SupabaseClient, assignmentId: string) => {
try {
console.log('🚀 CALLING RPC FUNCTION:', 'get_assignment_by_id');
console.log('🚀 WITH PARAMETER:', { p_id: assignmentId });
console.log('🚀 ASSIGNMENT ID TYPE:', typeof assignmentId);
console.log('🚀 ASSIGNMENT ID VALUE:', assignmentId);
const result = await supabase.rpc("get_assignment_by_id", { p_id: assignmentId });
console.log('🔍 RAW RPC RESULT:', JSON.stringify(result, null, 2));
console.log('🔍 RESULT.ERROR:', result.error);
console.log('🔍 RESULT.DATA:', result.data);
if (result.data && Array.isArray(result.data)) {
console.log('🔍 FIRST ELEMENT:', result.data[0]);
}
if (result.error) {
console.error('❌ RPC Error in getAssignmentById:', result.error);
console.error('❌ ERROR CODE:', result.error.code);
console.error('❌ ERROR MESSAGE:', result.error.message);
console.error('❌ ERROR DETAILS:', result.error.details);
throw new Error(`RPC function failed: ${result.error.message}`);
}
return result;
} catch (error) {
console.error('💥 CATCH BLOCK - Error calling get_assignment_by_id:', error);
console.error('💥 ERROR TYPE:', typeof error);
if (error instanceof Error) {
console.error('💥 ERROR MESSAGE:', error.message);
}
throw error;
}
};and this is the code where the actual function is being called:
const { data: assignmentData, error: assignmentError } = await getAssignmentById(supabase, id); const { data: assignmentData, error: assignmentError } = await getAssignmentById(supabase, id); I genuinely don't know what I am doing wrong this was working a few days ago.