Suggestion ID undefined when fetching new suggestions
Resolved 💬 3 comments Opened Nov 25, 2025 by eddy-lipstick Closed Jan 27, 2026
Bug Description
When clicking "Create Timeline" on a suggestion card, the suggestion ID is undefined, causing a 404 error when calling the generate endpoint.
Steps to Reproduce
- Navigate to a project dashboard with processed documents
- Click "Get Suggestions" or wait for auto-generated suggestions
- Click "Create Timeline" on a suggestion card
- Observe the error in console
Error
💡 Create Timeline clicked for suggestion: undefined
💡 handleCreateFromSuggestion called with: Object
💡 Fetching generate endpoint for suggestion: undefined
POST /api/folders/{folderId}/suggestions/undefined/generate 404 (Not Found)
Error: Suggestion not found or already dismissed
Root Cause
The getFolderSuggestions service function was updated to explicitly map database rows to include the id field, but newly generated suggestions (via POST /api/folders/[id]/suggestions) may not be returning the id from the database insert.
Files Involved
apps/web/src/lib/services/suggestion-service.ts-getFolderSuggestions()andsaveSuggestions()apps/web/src/app/api/folders/[id]/suggestions/route.ts- POST handlerapps/web/src/components/timeline/TimelineSuggestions.tsx- UI component
Expected Behavior
Suggestion objects should always have a valid id string that can be used to call the generate endpoint.
Suggested Fix
The POST handler in route.ts calls generateTimelineSuggestions() then saveSuggestions(), but saveSuggestions() doesn't return the inserted IDs. The fix should:
- Update
saveSuggestions()to return the inserted suggestions with their database-generated IDs - Or re-fetch suggestions after saving to get the IDs
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗