{"record":{"id":"43cc2df38cb735d2","repo":"decolua/9router","slug":"res-status-text","errorCode":null,"errorMessage":"[${res.status}] ${text}","messagePattern":"\\[\\$\\{res\\.status\\}\\] \\$\\{text\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"open-sse/executors/trae.js","lineNumber":128,"sourceCode":"        content: [],\n        query,\n        model_name: modelName,\n        agent_type: \"solo_agent_remote\",\n        model_selection_strategy: strategy,\n        common_params: this.commonParams(psd, mode),\n      },\n      env: \"remote\",\n      auto_create_project: false,\n      origin: \"web\",\n    };\n    const res = await proxyAwareFetch(`${this.base()}/chat_sessions`, {\n      method: \"POST\",\n      headers,\n      body: JSON.stringify(body),\n      signal,\n    }, null);\n    const text = await res.text();\n    if (!res.ok) throw new Error(`[${res.status}] ${text}`);\n    const json = JSON.parse(text);\n    if (json?.code !== 0) throw new Error(`Trae create_session: ${JSON.stringify(json)}`);\n    return { sessionId: json.data.chat_session_id, messageId: json.data.message_id };\n  }\n\n  // GET /events SSE → invoke onEvent(eventType, dataObj) per frame.\n  // Resolves when `done`/`error` arrives, the stream ends, or timeout fires.\n  async streamEvents(headers, sessionId, replyTo, onEvent, signal) {\n    const url = `${this.base()}/chat_sessions/${sessionId}/events?reply_to_message_id=${encodeURIComponent(replyTo)}`;\n    const ctrl = new AbortController();\n    if (signal?.aborted) ctrl.abort();\n    const timer = setTimeout(() => ctrl.abort(new Error(\"trae stream timeout\")), STREAM_TIMEOUT_MS);\n    const onAbort = () => ctrl.abort();\n    if (signal) signal.addEventListener(\"abort\", onAbort, { once: true });\n    try {\n      const res = await proxyAwareFetch(url, { method: \"GET\", headers, signal: ctrl.signal }, null);\n      if (!res.ok || !res.body) throw new Error(`[${res.status}] events stream failed`);\n      const reader = res.body.getReader();","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/open-sse/executors/trae.js#L110-L146","documentation":"Trae's executor first creates a chat session via a POST; createSession() treats a non-2xx response as fatal and throws this error embedding the status code and the raw response body. The library surfaces the body verbatim because Trae error pages/JSON usually contain the real cause (auth, quota, region).","triggerScenarios":"The Trae create-session endpoint returns an HTTP error status: expired/invalid auth token (401/403), rate limit (429), server error (5xx), or a proxy interception page (403/502). Raised from createSession, called by execute.","commonSituations":"Trae credential expired and needs re-login/refresh; account quota exhausted; Trae blocking the datacenter IP or requiring a different region endpoint; a corporate proxy returning an error page.","solutions":["Read the body in the message — 401/403 → refresh or re-authenticate the Trae credential; 429 → back off; 5xx → retry later","Re-authenticate the Trae account (token refresh or manual re-login) if auth expired","Retry the request; transient 5xx/network errors often clear","Bypass or reconfigure proxies that may return interception pages","Update 9router in case Trae changed its session endpoint contract","Implement account fallback so a failing Trae credential is skipped automatically"],"exampleFix":"// before\nconst s = await executor.createSession(...); // throws raw\n// after\nlet s;\ntry { s = await executor.createSession(...); }\ncatch (e) {\n  if (/\\[40[13]\\]/.test(e.message)) { await refreshTraeCredential(); s = await executor.createSession(...); }\n  else throw e;\n}","handlingStrategy":"retry","validationCode":"// pre-check credential validity before creating a session\nconst cred = await getTraeCredential();\nif (!cred || Date.now() > (cred.expiresAt ?? Infinity)) {\n  await refreshTraeCredential();\n}","typeGuard":null,"tryCatchPattern":"try {\n  session = await executor.createSession(...);\n} catch (e) {\n  const status = +String(e.message).match(/^\\[(\\d+)\\]/)?.[1] ?? 0;\n  if (status === 401 || status === 403) { await refreshTraeCredential(); return retry(); }\n  if (status === 429) { await sleep(backoff); return retry(); }\n  if (status >= 500) { return retryWithBackoff(); }\n  throw e;\n}","preventionTips":["Refresh Trae credentials before expiry","Enable multi-account fallback for quota/auth failures","Watch for proxy interception pages in the error body","Back off on 429 instead of hammering the endpoint"],"tags":["trae","http-status","session","authentication"],"backgroundTag":"upstream-http-error","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}