diff --git a/attached_assets/Pasted-1-TypeScript-Errors-in-Seed-Data-Edge-Function-File-supabase-functions-seed-test-data-index-ts-Li-1759931709146_1759931709146.txt b/attached_assets/Pasted-1-TypeScript-Errors-in-Seed-Data-Edge-Function-File-supabase-functions-seed-test-data-index-ts-Li-1759931709146_1759931709146.txt new file mode 100644 index 00000000..748c58d9 --- /dev/null +++ b/attached_assets/Pasted-1-TypeScript-Errors-in-Seed-Data-Edge-Function-File-supabase-functions-seed-test-data-index-ts-Li-1759931709146_1759931709146.txt @@ -0,0 +1,38 @@ +1. TypeScript Errors in Seed Data Edge Function + +File: supabase/functions/seed-test-data/index.ts +Line 125: Accessing user.id when user is possibly null +Line 286: Accessing error.message when error is type unknown +Impact: These will cause runtime errors when the function executes under certain conditions +2. Hot Module Replacement (HMR) Failures + +Files: src/pages/ManufacturerRides.tsx and src/pages/ManufacturerModels.tsx +Issue: Recent changes caused syntax errors preventing hot reload +Impact: Development workflow is broken for these pages +🟠 High Priority Issues +3. Potential Null Pointer Errors + +src/hooks/useNovuNotifications.ts: user?.id could be undefined when authentication state changes unexpectedly +src/components/admin/LocationSearch.tsx: setSelectedLocation(null) might cause issues in consuming components +src/components/admin/RideModelForm.tsx & ManufacturerForm.tsx: Using empty string '' as default for IDs instead of undefined or null +4. Race Conditions + +src/hooks/useEntityVersions.ts: Multiple fetches could complete out of order without explicit handling +src/components/upload/PhotoUpload.tsx: Multi-file uploads with Promise.all could leave partial state on failures +src/lib/systemActivityService.ts: Real-time subscription updates could conflict with ongoing data fetches +5. Error Handling Gaps + +Edge Functions: Several edge functions (upload-image, trigger-notification, update-novu-preferences) lack granular error handling around critical API calls +React Components: Some async operations in components don't have comprehensive error handling +🟡 Medium Priority Issues +6. Type Safety Issues + +src/components/search/AutocompleteSearch.tsx: Type assertion as SearchResult could be unsafe if object structure differs +src/components/companyHelpers.ts: extractImageAssignments assumes data.images.uploaded is always an array without validation +7. Memory Management Concerns + +src/hooks/useModerationQueue.ts: setInterval for polling queue stats (line 39) - cleanup appears to be present but verify it's working correctly +Note: useAuth hook cleanup is properly implemented ✅ +8. Input Validation + +Various forms default person_type to 'company' which might cause issues if it's not always a valid enum value \ No newline at end of file diff --git a/supabase/functions/seed-test-data/index.ts b/supabase/functions/seed-test-data/index.ts index 022bc6ee..0dbb1559 100644 --- a/supabase/functions/seed-test-data/index.ts +++ b/supabase/functions/seed-test-data/index.ts @@ -122,7 +122,7 @@ Deno.serve(async (req) => { } if (options.expiredLock) { - submissionData.assigned_to = user.id; + submissionData.assigned_to = userId; submissionData.locked_until = new Date(Date.now() - 1000 * 60 * 30).toISOString(); // 30 min ago } @@ -282,8 +282,9 @@ Deno.serve(async (req) => { } catch (error) { console.error('Seed error:', error); + const errorMessage = error instanceof Error ? error.message : 'An unknown error occurred'; return new Response( - JSON.stringify({ error: error.message }), + JSON.stringify({ error: errorMessage }), { status: 500, headers: { ...corsHeaders, 'Content-Type': 'application/json' } } ); }