{"record":{"id":"b070da8da7bfac69","repo":"Zie619/n8n-workflows","slug":"http-response-status-response-statustext","errorCode":null,"errorMessage":"HTTP ${response.status}: ${response.statusText}","messagePattern":"HTTP (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"static/index-nodejs.html","lineNumber":1079,"sourceCode":"      debounceSearch() {\n        clearTimeout(this.searchDebounceTimer);\n        this.searchDebounceTimer = setTimeout(() => {\n          this.state.currentPage = 1;\n          this.resetAndSearch();\n        }, 300);\n      }\n\n      async apiCall(endpoint, options = {}) {\n        const response = await fetch(`/api${endpoint}`, {\n          headers: {\n            'Content-Type': 'application/json',\n            ...options.headers\n          },\n          ...options\n        });\n\n        if (!response.ok) {\n          throw new Error(`HTTP ${response.status}: ${response.statusText}`);\n        }\n\n        return response.json();\n      }\n\n      async loadInitialData() {\n        this.showState('loading');\n\n        try {\n          // Load categories first, then stats and workflows\n          console.log('Loading categories...');\n          await this.loadCategories();\n\n          console.log('Categories loaded, populating filter...');\n          this.populateCategoryFilter();\n\n          // Load stats and workflows in parallel\n          console.log('Loading stats and workflows...');","sourceCodeStart":1061,"sourceCodeEnd":1097,"githubUrl":"https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/static/index-nodejs.html#L1061-L1097","documentation":"Thrown by apiCall() in the static dashboard page (static/index-nodejs.html) whenever a fetch to /api<endpoint> returns a non-2xx status: it raises Error(`HTTP ${status}: ${statusText}`). This is the single choke point for all backend calls of the workflow-dashboard UI (categories, stats, workflows, diagram), so any backend 4xx/5xx surfaces to the UI as this generic message.","triggerScenarios":"GET /api/stats or /api/workflows returning 404 (route removed / file missing), 500 (backend exception, e.g., unreadable workflow JSON on disk), 401/403 when auth is enabled and the session expired, or a dev server proxy mismatch where /api is served by the wrong process.","commonSituations":"Serving the static HTML against a backend whose route prefix changed; backend crash mid-request; large workflow file causing a parser error -> 500; browser session cookie expired; CORS/proxy misconfiguration in containerized setups.","solutions":["Open the failing /api URL directly (or the browser Network tab) to see the real status and response body — the statusText alone hides the cause.","404: verify the endpoint path matches the backend router and that the static file is served by the same app.","500: check the backend logs for the exception behind the response (often a malformed workflow JSON file).","Improve apiCall to include the response body in the thrown message (see exampleFix) so future failures self-describe."],"exampleFix":"// before\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}: ${response.statusText}`);\n}\nreturn response.json();\n\n// after - surface the server's own error detail\nif (!response.ok) {\n  let detail = '';\n  try { detail = (await response.text()).slice(0, 300); } catch (_) {}\n  throw new Error(`HTTP ${response.status}: ${response.statusText} on ${endpoint}${detail ? ' — ' + detail : ''}`);\n}\nreturn response.json();","handlingStrategy":"try-catch","validationCode":"// Nothing to validate before the call beyond the endpoint string:\nif (!endpoint || !endpoint.startsWith('/')) {\n  throw new Error(`Invalid endpoint: ${endpoint}`);\n}","typeGuard":"const isOkResponse = (r) => r instanceof Response && r.ok;","tryCatchPattern":"async function safeApiCall(endpoint, options = {}) {\n  try {\n    const response = await fetch(`/api${endpoint}`, { headers: { 'Content-Type': 'application/json', ...options.headers }, ...options });\n    if (!response.ok) {\n      const detail = (await response.text()).slice(0, 300);\n      throw new Error(`HTTP ${response.status}: ${response.statusText} on ${endpoint} — ${detail}`);\n    }\n    return await response.json();\n  } catch (e) {\n    showState('error', `Request failed: ${e.message}`);\n    throw e;\n  }\n}","preventionTips":["Always include the endpoint and (truncated) response body in HTTP error messages — statusText is almost never enough.","Check backend health/logs when the dashboard shows this error; the UI is only the messenger.","Keep the static bundle and the API router versioned together so /api routes and the page that calls them never drift."],"tags":["n8n","frontend","fetch","http-error","dashboard","rest-api"],"backgroundTag":null,"analyzedSha":"94007c1445d9258a7da116646b79473e7c7c3282","analyzedAt":"2026-08-15T04:10:37.591Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}