diegosouzapw/OmniRoute · error

Token validation failed

Error message

Token validation failed: ${error.message}

What it means

Final failure in KiroService.validateImportToken: both import strategies errored — the cached AWS SSO client credentials could not refresh the token (silently caught) AND the social-auth refresh path threw, with error.message wrapped. Neither Builder ID nor social auth accepted the token, so the import cannot be validated.

Solutions

  1. Read error.message to see which refresh endpoint and OAuth error dominated
  2. Confirm the token belongs to the region passed (default us-east-1)
  3. Treat persistent invalid_grant as a signal the token is revoked — ask the user for a fresh Kiro login
  4. Retry later if the failure was an AWS outage
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/lib/oauth/services/kiro.ts:376 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/507d8200596cb4b7. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/oauth/services/kiro.ts:376

          // only the social-auth path returns one, and Builder ID connections
          // don't require it. The Kiro executor adds profileArn conditionally.
          profileArn: result.profileArn,
          expiresIn: result.expiresIn,
          authMethod: "builder-id",
          clientId: cachedClient.clientId,
          clientSecret: cachedClient.clientSecret,
        };
      } catch {
        // Cached credentials didn't work, fall through
      }
    }

    // Attempt 2: Try social auth refresh
    let result: Awaited<ReturnType<typeof this.refreshToken>>;
    try {
      result = await this.refreshToken(refreshToken);
    } catch (error: any) {
      throw new Error(`Token validation failed: ${error.message}`);
    }

    // Register an independent OIDC client for this connection so multiple accounts
    // do not share a single Kiro backend session (issue #2328).
    let clientId: string | undefined;
    let clientSecret: string | undefined;
    let clientSecretExpiresAt: number | undefined;
    try {
      const registration = await this.registerClient(region);
      clientId = registration.clientId;
      clientSecret = registration.clientSecret;
      clientSecretExpiresAt = registration.clientSecretExpiresAt;
    } catch (err: any) {
      console.warn("[kiro import] registerClient failed, continuing without isolated client:", err);
    }

    return {
      accessToken: result.accessToken,

View on GitHub (pinned to a179ffed5b)