2.8 KiB
| phase | plan | type |
|---|---|---|
| 02-model-discovery | 01-FIX | fix |
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.mdIssues 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:
-
First, investigate the actual search response by adding debug logging:
- Log the raw response from Replicate search API
- Identify the actual response structure
-
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
-
Keep the existing
ReplicateSearchResponseinterface 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: [],
});
}
- 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
<success_criteria>
- UAT-001 resolved - search endpoint no longer crashes
- Defensive null checks in place
- No regression in list functionality </success_criteria>