{"record":{"id":"2c7e467a5f07ef1c","repo":"diegosouzapw/OmniRoute","slug":"amelia-init-failed-res-status","errorCode":null,"errorMessage":"Amelia init failed: ${res.status}","messagePattern":"Amelia init failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"open-sse/executors/chipotle.ts","lineNumber":46,"sourceCode":"class AmeliaClient {\n  private session: AmeliaSession | null = null;\n  private ws: import(\"ws\").WebSocket | null = null;\n  private stompConnected = false;\n  private messageCallbacks: Map<string, (msg: string) => void> = new Map();\n  private connectPromise: Promise<void> | null = null;\n\n  async init(): Promise<void> {\n    const res = await fetch(`${BASE_URL}/Amelia/api/init`, {\n      headers: {\n        \"User-Agent\":\n          \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36\",\n        Origin: BASE_URL,\n        Referer: `${BASE_URL}/Amelia/ui/chipotle/chat?embed=iframe`,\n      },\n      redirect: \"manual\",\n    });\n\n    if (!res.ok) throw new Error(`Amelia init failed: ${res.status}`);\n\n    const data = (await res.json()) as {\n      csrfToken: string;\n      user: { userId: string; anonymous: boolean };\n    };\n\n    const setCookies = res.headers.getSetCookie?.() ?? [];\n    const cookieHeader = setCookies.map((c) => c.split(\";\")[0]).join(\"; \");\n\n    this.session = {\n      csrfToken: data.csrfToken,\n      userId: data.user.userId,\n      cookieHeader,\n    };\n  }\n\n  async connect(): Promise<void> {\n    if (!this.session) throw new Error(\"Call init() first\");","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/open-sse/executors/chipotle.ts#L28-L64","documentation":"AmeliaClient.init() got a non-2xx HTTP status from the Amelia web-client bootstrap endpoint (GET `${BASE_URL}/Amelia/api/init`), so the session/WebSocket handshake never started. The status code is interpolated into the message. Typically the site is up but rejecting the synthetic browser request (bot protection such as Cloudflare, stale User-Agent/Origin headers) or the Amelia service is temporarily unavailable — a transient upstream condition, not a code defect.","triggerScenarios":"Thrown at open-sse/executors/chipotle.ts:46 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry init after a short backoff — transient 5xx/bot-protection responses often clear on the next request","Update the User-Agent, Origin and Referer headers to match a current real browser; a stale Chrome version string is a common trigger","Check whether BASE_URL is still the correct Amelia host and that the service is reachable outside the proxy","If the provider keeps failing, rotate to another Amelia connection or let combo routing fall back to a different provider"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}