decolua/9router · error · Error

`Trae GetLoginGuidance failed: ${lastErr}`

Error message

`Trae GetLoginGuidance failed: ${lastErr}`

What it means

Thrown by fetchTraeLoginGuidance after it exhausts every candidate URL: each attempt either threw (network/parse failure) or returned a response lacking a LoginHost field, and lastErr records the final failure. Means the Trae login-guidance API never yielded a usable login host, so the browser sign-in URL cannot be built.

Source

Thrown at src/lib/oauth/providers/trae.js:50

        headers: {
          Accept: "application/json",
          "Content-Type": "application/json",
          "User-Agent": TRAE_CONFIG.userAgent,
        },
        body,
      });
      if (!res.ok) { lastErr = `${url} HTTP ${res.status}`; continue; }
      const data = await res.json();
      const loginHost = extractJsonPath(data, [
        ["Result", "LoginHost"], ["Result", "loginHost"], ["Result", "LoginURL"],
        ["result", "loginHost"], ["data", "Result", "LoginHost"], ["data", "loginHost"],
        ["LoginHost"], ["loginHost"],
      ]);
      if (loginHost) return loginHost;
      lastErr = `${url} missing LoginHost`;
    } catch (e) { lastErr = `${url} ${e.message}`; }
  }
  throw new Error(`Trae GetLoginGuidance failed: ${lastErr}`);
}

// Build the browser verification URL the user opens to sign in.
function buildTraeVerificationUrl(loginHost, loginTraceId, callbackUrl, ctx) {
  const url = new URL(loginHost.startsWith("http") ? loginHost : `https://${loginHost.replace(/^\/+/, "")}`);
  url.pathname = TRAE_CONFIG.authorizationPath;
  const p = new URLSearchParams();
  p.set("login_version", "1");
  p.set("auth_from", "trae");
  p.set("login_channel", "native_ide");
  p.set("plugin_version", ctx.plugin_version);
  p.set("auth_type", "local");
  p.set("client_id", TRAE_CONFIG.clientId);
  p.set("redirect", "0");
  p.set("login_trace_id", loginTraceId);
  p.set("auth_callback_url", callbackUrl);
  p.set("machine_id", ctx.machine_id);
  p.set("device_id", ctx.device_id);

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Read lastErr in the message: 'missing LoginHost' → the response schema changed, update the key extraction list; otherwise it's a network/HTTP failure.
  2. Verify the Trae guidance endpoint URL is current (check for provider-side API changes) and reachable with curl.
  3. Check DNS/proxy/firewall for the Trae domain if the error is a fetch exception.
  4. Retry later if the Trae API is having an outage.
Defensive patterns

Strategy: fallback

Validate before calling

async function traeeReachable(url) {
  try { const r = await fetch(url, { method: 'HEAD' }); return r.ok; } catch { return false; }
}

Try / catch

try {
  const guidance = await fetchTraeLoginGuidance(ctx);
} catch (e) {
  if (e.message.startsWith('Trae GetLoginGuidance failed:')) {
    // check lastErr: 'missing LoginHost' → schema change; otherwise network — retry or report outage
  } else throw e;
}

Prevention

When it happens

Trigger: All configured guidance URLs fail: Trae API unreachable/DNS failure, endpoint changed shape and no longer returns LoginHost/LoginHost key, 4xx/5xx responses, or a fetch rejection (timeout, TLS).

Common situations: Trae changed their GetLoginGuidance response schema after a server update; corporate proxy/DNS blocks the Trae domain; running fully offline; regional endpoint deprecated.

Related errors


AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30). Data as JSON: /api/errors/0728884916634df7. Report an issue: GitHub.