Repository navigation
fix(providers): refresh Trae's stale Referer/Origin and forward user timezone (#12190) - #13255
Merged
Merged
Conversation
Githab-capibara
added a commit
to Githab-capibara/OmniRoute
that referenced
this pull request
Sep 17, 2026
…timezone (cheaper-inference#12190) (cheaper-inference#13255) Merged as part of the owner batch of 2026-09-11. This PR had a live worktree in another session, so it sat outside the main 39. Merged on your explicit call, validated first rather than taken on trust: boarded with the other 10 worktree-held PRs into a consolidated worktree off `release/v3.8.51`. - ESLint over every changed file: no errors - `typecheck:core` clean; `check:dashboard-typecheck` OK; `check:changelog-integrity` OK - complexity 2821 / baseline 3218 and cognitive-complexity 1272 / baseline 1437 - 203 of 208 assertions green. The 5 remaining (`guide-settings-route` ×4, `hard-session-lease-bypass-inventory` ×1) reproduce on the pure tip with nothing from this batch applied. - `imageGeneration.ts` rebaselined 3259 → 3293 for cheaper-inference#12945's image-only-model guard, landed separately in cheaper-inference#13392 so nothing was pushed onto a live branch.⚠️ base-red inherited: cheaper-inference#12732 — provider count 356 vs 358 and `open-sse/utils/stream.ts` 3115 > frozen 3098, both reproducing on the pure tip.
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…timezone (cheaper-inference#12190) (cheaper-inference#13255) Merged as part of the owner batch of 2026-09-11. This PR had a live worktree in another session, so it sat outside the main 39. Merged on your explicit call, validated first rather than taken on trust: boarded with the other 10 worktree-held PRs into a consolidated worktree off `release/v3.8.51`. - ESLint over every changed file: no errors - `typecheck:core` clean; `check:dashboard-typecheck` OK; `check:changelog-integrity` OK - complexity 2821 / baseline 3218 and cognitive-complexity 1272 / baseline 1437 - 203 of 208 assertions green. The 5 remaining (`guide-settings-route` ×4, `hard-session-lease-bypass-inventory` ×1) reproduce on the pure tip with nothing from this batch applied. - `imageGeneration.ts` rebaselined 3259 → 3293 for cheaper-inference#12945's image-only-model guard, landed separately in cheaper-inference#13392 so nothing was pushed onto a live branch.⚠️ base-red inherited: cheaper-inference#12732 — provider count 356 vs 358 and `open-sse/utils/stream.ts` 3115 > frozen 3098, both reproducing on the pure tip.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
TraeExecutor.buildHeaders()(open-sse/executors/trae.ts) hardcodedReferer: "https://solo.trae.ai/", sent noOriginheader at all, and could only ever resolvex-user-regionto"US"— none of the three places that buildproviderSpecificData(the manual import routesrc/app/api/oauth/trae/import/route.ts, the/authorizecallback parsersrc/app/authorize/parseCallback.ts, andmapTokens()insrc/lib/oauth/providers/trae.ts, which both real creation paths bypass) ever populated a non-"US"userRegionor any timezone value. Trae's backend validates Origin/Referer against the JWT session's real origin, which has moved towork.trae.ai, producing a clean 401 even with a fresh, valid token.Verification of the current upstream expectation
Per the task note, I did not hardcode a new point-in-time domain blindly:
_references/_sistemas_proxys/(command grep, since these dirs are gitignored) fortrae.ai— the only hits were the9routerupstream mirror (which carries the same stalesolo.trae.aivalue we're fixing) andcockpit-tools(a Trae desktop-account manager), which only covers the China (trae.cn) account/checkin surface, not the SOLO/Work remote-agent chat API this executor talks to. Neither is authoritative here.https://solo.trae.ai/andhttps://work.trae.ai/today both resolve to the same "TraeWork" product page, confirmingsolo.trae.aihas been folded into thework.trae.aisurface — consistent with the reporter's finding.TRAE_WEB_ORIGIN(env, for a fleet-wide bump without a redeploy of code) and can be overridden per-connection viaproviderSpecificData.refererOrigin, falling back tohttps://work.trae.aionly when neither is set.Fix
open-sse/executors/trae.ts:buildHeaders()now derives Referer/Origin fromTRAE_WEB_ORIGINenv (defaulthttps://work.trae.ai) or a per-connectionproviderSpecificData.refererOriginoverride, and forwardsx-trae-user-timezonefromproviderSpecificData.userTimezonewhen present (omitted otherwise, matching prior behavior for accounts with no timezone on file).src/app/api/oauth/trae/import/route.ts: accepts optionaluserRegion/userTimezonefields instead of hardcodingproviderSpecificData.userRegion: "US"; exposes them in theGETfield-metadata so the dashboard import form can capture them. Default stays"US"when the caller leaves them blank, so existing imports keep behaving as before.src/shared/validation/schemas/auth.ts:traeImportSchemagains optionaluserRegion/userTimezone.src/app/authorize/parseCallback.ts: best-effort forwardsuserRegion/userTimezonefrom the OAuth callback'suserInfopayload if Trae ever includes them underUserRegion/Timezone; staysundefined(i.e. no behavior change) otherwise, since I could not find prior evidence these keys exist in this payload.src/lib/oauth/providers/trae.ts:mapTokens()also acceptsuserTimezone/user_timezonefor parity, though both direct creation paths above bypass this function already (pre-existing, noted in the original triage).Regression test
tests/unit/trae-headers-12190.test.ts(new file). RED before the fix (matches the plan's proven repro exactly):GREEN after the fix — all 6 cases pass (freshness, timezone forwarding, timezone omission when absent, custom
userRegionrespected, default region, per-connection origin override).Gates run
node --import tsx/esm --test tests/unit/trae-headers-12190.test.ts→ 6/6 pass (new)node --import tsx/esm --test tests/unit/trae-executor.test.ts→ 16/16 pass (existing, unmodified — no assertion on Referer/Origin values existed, so nothing needed realigning)node --import tsx/esm --test tests/unit/oauth-trae.test.ts→ 13/13 pass (existing, unmodified)node scripts/check/check-file-size.mjs→ OKnode scripts/check/check-complexity.mjs→ OKnode scripts/check/check-cognitive-complexity.mjs→ OKnpm run typecheck:core→ exit 0npx eslint --suppressions-location config/quality/eslint-suppressions.json <changed files>→ exit 0node scripts/check/check-changelog-integrity.mjs→ OKCloses #12190