Zie619/n8n-workflows · error · Error

HTTP ${response.status}: ${response.statusText}

Error message

HTTP ${response.status}: ${response.statusText}

What it means

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.

Source

Thrown at static/index-nodejs.html:1079

      debounceSearch() {
        clearTimeout(this.searchDebounceTimer);
        this.searchDebounceTimer = setTimeout(() => {
          this.state.currentPage = 1;
          this.resetAndSearch();
        }, 300);
      }

      async apiCall(endpoint, options = {}) {
        const response = await fetch(`/api${endpoint}`, {
          headers: {
            'Content-Type': 'application/json',
            ...options.headers
          },
          ...options
        });

        if (!response.ok) {
          throw new Error(`HTTP ${response.status}: ${response.statusText}`);
        }

        return response.json();
      }

      async loadInitialData() {
        this.showState('loading');

        try {
          // Load categories first, then stats and workflows
          console.log('Loading categories...');
          await this.loadCategories();

          console.log('Categories loaded, populating filter...');
          this.populateCategoryFilter();

          // Load stats and workflows in parallel
          console.log('Loading stats and workflows...');

View on GitHub (pinned to 94007c1445)

Solutions

  1. 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.
  2. 404: verify the endpoint path matches the backend router and that the static file is served by the same app.
  3. 500: check the backend logs for the exception behind the response (often a malformed workflow JSON file).
  4. Improve apiCall to include the response body in the thrown message (see exampleFix) so future failures self-describe.

Example fix

// before
if (!response.ok) {
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
return response.json();

// after - surface the server's own error detail
if (!response.ok) {
  let detail = '';
  try { detail = (await response.text()).slice(0, 300); } catch (_) {}
  throw new Error(`HTTP ${response.status}: ${response.statusText} on ${endpoint}${detail ? ' — ' + detail : ''}`);
}
return response.json();
Defensive patterns

Strategy: try-catch

Validate before calling

// Nothing to validate before the call beyond the endpoint string:
if (!endpoint || !endpoint.startsWith('/')) {
  throw new Error(`Invalid endpoint: ${endpoint}`);
}

Type guard

const isOkResponse = (r) => r instanceof Response && r.ok;

Try / catch

async function safeApiCall(endpoint, options = {}) {
  try {
    const response = await fetch(`/api${endpoint}`, { headers: { 'Content-Type': 'application/json', ...options.headers }, ...options });
    if (!response.ok) {
      const detail = (await response.text()).slice(0, 300);
      throw new Error(`HTTP ${response.status}: ${response.statusText} on ${endpoint} — ${detail}`);
    }
    return await response.json();
  } catch (e) {
    showState('error', `Request failed: ${e.message}`);
    throw e;
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Zie619/n8n-workflows@94007c1445 (2026-08-15). Data as JSON: /api/errors/b070da8da7bfac69. Report an issue: GitHub.