diegosouzapw/OmniRoute · error · Error
Trae ExchangeToken: response missing Result.Token
Error message
Trae ExchangeToken: response missing Result.Token
What it means
Trae ExchangeToken succeeded (HTTP 200, valid JSON, no error code) but the payload lacked Result.Token, so no usable access token was returned. This is an unexpected response shape — likely an upstream schema change or partial success envelope.
Solutions
- Log the full parsed payload to detect schema drift
- Fail the refresh cleanly so the connection falls back on the next request
- Add a regression test pinning the expected response shape
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at open-sse/executors/trae.ts:471 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/367aeb54212a4ed7.
Report an issue: GitHub.
Appendix: source
Thrown at open-sse/executors/trae.ts:471
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");
}
return {
accessToken: result.Token as string,
refreshToken: (result.RefreshToken as string) || refreshToken,
expiresAt: result.TokenExpireAt
? new Date(Number(result.TokenExpireAt)).toISOString()
: undefined,
};
}
}
export default TraeExecutor;
View on GitHub (pinned to a179ffed5b)