{"record":{"id":"57d8d57b2d9349fd","repo":"diegosouzapw/OmniRoute","slug":"trae-exchangetoken-http-res-status-text-slic","errorCode":null,"errorMessage":"Trae ExchangeToken HTTP ${res.status}: ${text.slice(0, 200)}","messagePattern":"Trae ExchangeToken HTTP (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"open-sse/executors/trae.ts","lineNumber":454,"sourceCode":"   */\n  async refreshCredentials(credentials) {\n    const psd = (credentials?.providerSpecificData as JsonRecord) || {};\n    const refreshToken = credentials?.refreshToken as string | undefined;\n    if (!refreshToken) return null;\n    const host = ((psd.host as string) || \"https://api-us-east.trae.ai\").replace(/\\/$/, \"\");\n    const clientId =\n      (psd.clientId as string) || resolvePublicCred(\"trae_id\", \"TRAE_OAUTH_CLIENT_ID\");\n    const url = `${host}/cloudide/api/v3/trae/oauth/ExchangeToken`;\n    const body = { ClientID: clientId, RefreshToken: refreshToken, ClientSecret: \"-\", UserID: \"\" };\n\n    const res = await fetch(url, {\n      method: \"POST\",\n      headers: { \"Content-Type\": \"application/json\" },\n      body: JSON.stringify(body),\n    });\n    const text = await res.text();\n    if (!res.ok) {\n      throw new Error(`Trae ExchangeToken HTTP ${res.status}: ${text.slice(0, 200)}`);\n    }\n    let parsed;\n    try {\n      parsed = JSON.parse(text);\n    } catch {\n      throw new Error(\"Trae ExchangeToken: response was not JSON\");\n    }\n    const errCode = parsed?.ResponseMetadata?.Error?.Code;\n    if (errCode) {\n      // Surface invalid-refresh to the caller — BaseExecutor.execute swallows the\n      // refresh exception, but the next request will hit 401 and trigger fallback;\n      // we also leave the (stale) accessToken in place so observability shows why.\n      throw new Error(`Trae ExchangeToken error: ${errCode}`);\n    }\n    const result = parsed?.Result;\n    if (!result?.Token) {\n      throw new Error(\"Trae ExchangeToken: response missing Result.Token\");\n    }","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/open-sse/executors/trae.ts#L436-L472","documentation":"Error \"Trae ExchangeToken HTTP ${res.status}: ${text.slice(0, 200)}\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at open-sse/executors/trae.ts:454 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}