You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

2.8 KiB

phase plan type
02-model-discovery 01-FIX fix
Fix 1 UAT issue from plan 02-01.

Source: 02-01-ISSUES.md Priority: 0 critical, 1 major, 0 minor

<execution_context> @~/.claude/get-shit-done/workflows/execute-phase.md @~/.claude/get-shit-done/templates/summary.md </execution_context>

@.planning/STATE.md @.planning/ROADMAP.md

Issues being fixed: @.planning/phases/02-model-discovery/02-01-ISSUES.md

Original plan for reference: @.planning/phases/02-model-discovery/02-01-PLAN.md

Task 1: Fix UAT-001 - Search endpoint "undefined.map" error src/app/api/providers/replicate/models/route.ts Fix the Replicate search endpoint handling.

Root cause: The code assumes search returns { results: [{ model: {...} }] } but the actual Replicate search API response structure is different, causing data.results to be undefined.

Fix approach:

  1. First, investigate the actual search response by adding debug logging:

    • Log the raw response from Replicate search API
    • Identify the actual response structure
  2. Update the code to handle the correct structure:

    • The Replicate search API may return models differently (e.g., at root level, different field names)
    • Add defensive null checks: if (!data.results) { ... }
    • Return appropriate error or empty array if no results
  3. Keep the existing ReplicateSearchResponse interface or update it based on findings

Safety: Add null check before .map() call:

if (!data.results) {
  console.log(`[Replicate:${requestId}] Search returned no results`);
  return NextResponse.json<ModelsSuccessResponse>({
    success: true,
    models: [],
  });
}
  1. Update the provider file (src/lib/providers/replicate.ts) with same fix if searchModels() has similar issue. curl "http://localhost:3000/api/providers/replicate/models?search=flux&api_key=YOUR_KEY" returns success:true with models array (may be empty if no matches)
  • Search endpoint returns 200 with models array (not error)
  • If no results, returns empty array (not crash)
  • List endpoint still works unchanged
Before declaring plan complete: - [ ] Search query returns success:true (not error) - [ ] List endpoint still works: `curl "http://localhost:3000/api/providers/replicate/models"` with API key - [ ] TypeScript compiles: `npx tsc --noEmit` - [ ] Build succeeds: `npm run build`

<success_criteria>

  • UAT-001 resolved - search endpoint no longer crashes
  • Defensive null checks in place
  • No regression in list functionality </success_criteria>
After completion, create `.planning/phases/02-model-discovery/02-01-FIX-SUMMARY.md`