{"record":{"id":"047462dae1b091ac","repo":"windmill-labs/windmill","slug":"generic-error-status-errorstatus-status-text","errorCode":null,"errorMessage":"Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}","messagePattern":"Generic Error: status: (.+?); status text: (.+?); body: (.+?)","errorType":"http","errorClass":"ApiError","httpStatus":null,"severity":"error","filePath":"backend/windmill-runtime-nativets/src/windmill-client.js","lineNumber":3610,"sourceCode":"    510: \"Not Extended\",\n    511: \"Network Authentication Required\",\n    ...options.errors,\n  };\n  const error = errors[result.status];\n  if (error) {\n    throw new ApiError(options, result, error);\n  }\n  if (!result.ok) {\n    const errorStatus = result.status ?? \"unknown\";\n    const errorStatusText = result.statusText ?? \"unknown\";\n    const errorBody = (() => {\n      try {\n        return JSON.stringify(result.body, null, 2);\n      } catch (e) {\n        return void 0;\n      }\n    })();\n    throw new ApiError(\n      options,\n      result,\n      `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`\n    );\n  }\n};\nvar request = (config, options) => {\n  return new CancelablePromise(async (resolve2, reject, onCancel) => {\n    try {\n      const url = getUrl(config, options);\n      const formData = getFormData(options);\n      const body = getRequestBody(options);\n      const headers = await getHeaders(config, options);\n      if (!onCancel.isCancelled) {\n        let response = await sendRequest(\n          config,\n          options,\n          url,","sourceCodeStart":3592,"sourceCodeEnd":3628,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-runtime-nativets/src/windmill-client.js#L3592-L3628","documentation":"When the API returns a non-2xx status that has NO entry in the client's status-to-message map (e.g. unusual/custom codes or statuses not enumerated), the client falls back to this generic message embedding the status, status text, and a JSON-stringified body. The real diagnostic information is in the interpolated errorBody, not the message text itself.","triggerScenarios":"A windmill-client request receives a non-2xx response whose status code is absent from the default errors map and any options.errors overrides — e.g. proxy/CDN-generated codes (520s), custom middleware statuses, or 418 before a custom override.","commonSituations":"Requests routed through a reverse proxy or API gateway that injects its own error statuses, an OpenAPI spec/codegen mismatch where a documented status wasn't in the generated errors map, or non-JSON error bodies that stringify oddly.","solutions":["Parse the status, statusText and body from the thrown ApiError's response object — the generic message contains them verbatim.","If the status is meaningful and recurring, extend the client with options.errors so future errors get a clear message.","Check what sits between the client and Windmill (proxy, load balancer) for statuses like 520/522.","Inspect the server-side request logs using the endpoint and trace data from the response body."],"exampleFix":"// before\ncatch (e) { console.log(e.message); } // 'Generic Error: status: 522; ...'\n// after\ncatch (e) {\n  if (e instanceof ApiError) {\n    console.error(`API ${e.status} ${e.statusText}:`, e.body);\n  } else throw e;\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isApiErrorWithBody(e) { return e instanceof ApiError && e.body !== undefined && e.status !== undefined; }","tryCatchPattern":"try {\n  await client.someCall(args);\n} catch (e) {\n  if (isApiErrorWithBody(e)) {\n    console.error(`Unmapped HTTP ${e.status} (${e.statusText}):`, e.body);\n    // branch on e.status / e.body.error\n  } else throw e;\n}","preventionTips":["Always log the ApiError's status and body — the generic message is not the diagnostic.","Register custom statuses via options.errors when a proxy introduces its own codes.","Inspect intermediary infrastructure (reverse proxy/gateway) when statuses are non-standard."],"tags":["http","api-client","fallback-error","network"],"backgroundTag":"http-non-2xx-response","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}