diegosouzapw/OmniRoute · error

Invalid token format. Token appears too short.

Error message

Invalid token format. Token appears too short.

What it means

Length heuristic in validateImportToken: a string accessToken shorter than 50 characters is rejected because real Cursor tokens are long opaque strings. Indicates the value read from state.vscdb/auth.json is truncated, a placeholder, or not actually the access token (e.g. a wrong SQLite column was read).

Solutions

  1. Re-extract the token from Cursor's state.vscdb / auth.json, confirming the correct key (not a truncated or placeholder value)
  2. Ensure no trimming/encoding step corrupted the token
  3. If the token is genuinely short, verify Cursor's current token format and adjust the threshold
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/lib/oauth/services/cursor.ts:108 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


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

Appendix: source

Thrown at src/lib/oauth/services/cursor.ts:108

    return "x86_64";
  }

  /**
   * Validate and import token from Cursor IDE or cursor-agent CLI.
   * Note: We skip API validation because Cursor API uses complex protobuf format.
   * Token will be validated when actually used for requests.
   * @param {string} accessToken - Access token from state.vscdb or auth.json
   * @param {string} [machineId] - Machine ID from state.vscdb (optional for cursor-agent imports)
   */
  async validateImportToken(accessToken: string, machineId?: string) {
    // Basic validation
    if (!accessToken || typeof accessToken !== "string") {
      throw new Error("Access token is required");
    }

    // Token format validation (Cursor tokens are typically long strings)
    if (accessToken.length < 50) {
      throw new Error("Invalid token format. Token appears too short.");
    }

    // Machine ID format validation (only if provided — cursor-agent imports don't have one)
    if (machineId) {
      const uuidRegex = /^[a-f0-9-]{32,}$/i;
      if (!uuidRegex.test(machineId.replace(/-/g, ""))) {
        throw new Error("Invalid machine ID format. Expected UUID format.");
      }
    }

    // Note: We don't validate against API because Cursor uses complex protobuf.
    // Token will be validated when used for actual requests.

    return {
      accessToken,
      machineId: machineId || null,
      expiresIn: 86400, // Cursor tokens typically last 24 hours
      authMethod: machineId ? "imported" : "cursor-agent",

View on GitHub (pinned to a179ffed5b)