{"record":{"id":"8e704ca0506c43b0","repo":"BloopAI/vibe-kanban","slug":"invalid-response-from-file-system-api","errorCode":null,"errorMessage":"Invalid response from file system API","messagePattern":"Invalid response from file system API","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/web-core/src/shared/dialogs/shared/FolderPickerDialog.tsx","lineNumber":72,"sourceCode":"    }, [entries, searchTerm]);\n\n    useEffect(() => {\n      if (modal.visible) {\n        setManualPath(value);\n        loadDirectory();\n      }\n    }, [modal.visible, value]);\n\n    const loadDirectory = async (path?: string) => {\n      setLoading(true);\n      setError('');\n\n      try {\n        const result: DirectoryListResponse = await fileSystemApi.list(path);\n\n        // Ensure result exists and has the expected structure\n        if (!result || typeof result !== 'object') {\n          throw new Error('Invalid response from file system API');\n        }\n        // Safely access entries, ensuring it's an array\n        const entries = Array.isArray(result.entries) ? result.entries : [];\n        setEntries(entries);\n        const newPath = result.current_path || '';\n        setCurrentPath(newPath);\n        // Update manual path if we have a specific path (not for initial home directory load)\n        if (path) {\n          setManualPath(newPath);\n        }\n      } catch (err) {\n        setError(\n          err instanceof Error ? err.message : 'Failed to load directory'\n        );\n        // Reset entries to empty array on error\n        setEntries([]);\n      } finally {\n        setLoading(false);","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/BloopAI/vibe-kanban/blob/4deb7eca8f381f7cbc1f9d15515a9ab8f8009053/packages/web-core/src/shared/dialogs/shared/FolderPickerDialog.tsx#L54-L90","documentation":"In FolderPickerDialog's loadDirectory, the response of `fileSystemApi.list(path)` is validated before use: if it is null/undefined or not an object, the code throws 'Invalid response from file system API'. This indicates the file-system API endpoint returned something the dialog cannot interpret (empty body, error payload, or a non-JSON response) instead of a DirectoryListResponse.","triggerScenarios":"Calling fileSystemApi.list(path) where the backend responds with an empty body, an HTML error page, a null JSON literal, or any non-object payload that fails the `result && typeof result === 'object'` check.","commonSituations":"Backend proxy/auth failures returning error pages; a remote host where the file-system service is unreachable and the transport unwraps to null; version mismatch where an older/newer backend returns a differently-shaped payload; network middleware swallowing errors into undefined.","solutions":["Check the network tab/backend logs for what the file-system list endpoint actually returned (status code, body).","Ensure the API client throws on non-2xx responses instead of resolving with the error body.","Verify the backend file-system service is running and reachable for the selected host.","Confirm frontend/backend versions match so DirectoryListResponse serialization is compatible."],"exampleFix":"// before\nconst result = await fileSystemApi.list(path);\n// after\nconst res = await fetch(listUrl);\nif (!res.ok) throw new Error(`File system API returned ${res.status}`);\nconst result = await res.json();","handlingStrategy":"type-guard","validationCode":"const isDirectoryListResponse = (v: unknown): v is DirectoryListResponse =>\n  typeof v === 'object' && v !== null &&\n  Array.isArray((v as DirectoryListResponse).entries);","typeGuard":"function isDirectoryListResponse(v: unknown): v is DirectoryListResponse {\n  return (\n    typeof v === 'object' &&\n    v !== null &&\n    'entries' in v &&\n    Array.isArray((v as { entries: unknown }).entries)\n  );\n}","tryCatchPattern":"try {\n  await loadDirectory(path);\n} catch (err) {\n  if (err instanceof Error && err.message === 'Invalid response from file system API') {\n    showEmptyState('Could not read directory');\n  }\n}","preventionTips":["Make the API client throw on non-2xx HTTP statuses instead of resolving error bodies","Validate response shape at the API-client boundary, not deep in components","Monitor backend health of the file-system service for the active host"],"tags":["network","api-response","validation","file-system"],"backgroundTag":"invalid-api-response","analyzedSha":"4deb7eca8f381f7cbc1f9d15515a9ab8f8009053","analyzedAt":"2026-08-29T09:24:13.446Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}