diegosouzapw/OmniRoute · error · Error

Trae ExchangeToken HTTP ${res.status}: ${text.slice(0, 200)}

Error message

Trae ExchangeToken HTTP ${res.status}: ${text.slice(0, 200)}

What it means

Error "Trae ExchangeToken HTTP ${res.status}: ${text.slice(0, 200)}" thrown in diegosouzapw/OmniRoute.

Source

Thrown at open-sse/executors/trae.ts:454

   */
  async refreshCredentials(credentials) {
    const psd = (credentials?.providerSpecificData as JsonRecord) || {};
    const refreshToken = credentials?.refreshToken as string | undefined;
    if (!refreshToken) return null;
    const host = ((psd.host as string) || "https://api-us-east.trae.ai").replace(/\/$/, "");
    const clientId =
      (psd.clientId as string) || resolvePublicCred("trae_id", "TRAE_OAUTH_CLIENT_ID");
    const url = `${host}/cloudide/api/v3/trae/oauth/ExchangeToken`;
    const body = { ClientID: clientId, RefreshToken: refreshToken, ClientSecret: "-", UserID: "" };

    const res = await fetch(url, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(body),
    });
    const text = await res.text();
    if (!res.ok) {
      throw new Error(`Trae ExchangeToken HTTP ${res.status}: ${text.slice(0, 200)}`);
    }
    let parsed;
    try {
      parsed = JSON.parse(text);
    } catch {
      throw new Error("Trae ExchangeToken: response was not JSON");
    }
    const errCode = parsed?.ResponseMetadata?.Error?.Code;
    if (errCode) {
      // Surface invalid-refresh to the caller — BaseExecutor.execute swallows the
      // refresh exception, but the next request will hit 401 and trigger fallback;
      // we also leave the (stale) accessToken in place so observability shows why.
      throw new Error(`Trae ExchangeToken error: ${errCode}`);
    }
    const result = parsed?.Result;
    if (!result?.Token) {
      throw new Error("Trae ExchangeToken: response missing Result.Token");
    }

View on GitHub (pinned to a179ffed5b)

When it happens

Trigger: Thrown at open-sse/executors/trae.ts:454 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/57d8d57b2d9349fd. Report an issue: GitHub.