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

  1. Navigate to a project dashboard with processed documents
  2. Click "Get Suggestions" or wait for auto-generated suggestions
  3. Click "Create Timeline" on a suggestion card
  4. 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() and saveSuggestions()
  • apps/web/src/app/api/folders/[id]/suggestions/route.ts - POST handler
  • apps/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:

  1. Update saveSuggestions() to return the inserted suggestions with their database-generated IDs
  2. Or re-fetch suggestions after saving to get the IDs

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗