Kong/insomnia · error

Failed to initiate the GitLab OAuth flow

Error message

Failed to initiate the GitLab OAuth flow: ${errorMessage}

What it means

Wrapper error in the GitLab provider's initiateOAuth: building or opening the GitLab authorization URL (PKCE parameters, redirect URI, shell.openExternal) threw unexpectedly. The original error message is interpolated after the fixed prefix.

Solutions

  1. Read the embedded errorMessage for the underlying cause
  2. Verify GitLab app client ID and redirect configuration and that external browser opening works
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/insomnia/src/sync/git/providers/gitlab.ts:373 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Kong/insomnia@d9bb2b0142 (2026-08-26). Data as JSON: /api/errors/761bf62d72d5e4cf. Report an issue: GitHub.

Appendix: source

Thrown at packages/insomnia/src/sync/git/providers/gitlab.ts:373

        client_id: clientId,
        scope,
        state,
        response_type: 'code',
        redirect_uri: redirectUri,
        code_challenge: challenge,
        code_challenge_method: 'S256',
      }).toString();

      await shell.openExternal(gitlabURL.toString());

      return {
        authUrl: gitlabURL.toString(),
        state,
      };
    } catch (error) {
      const errorMessage = error instanceof Error ? error.message : String(error);
      console.error('Failed to initiate the GitLab OAuth flow:', error);
      throw new Error(`Failed to initiate the GitLab OAuth flow: ${errorMessage}`);
    }
  }

  /**
   * Complete OAuth flow with PKCE
   * Exchanges code for token and creates/updates credential in database
   */
  async completeOAuth(code: string, state: string): Promise<OAuthCompleteResult> {
    try {
      // Validate state and get verifier for PKCE
      let verifier = gitlabStatesCache.get(state)?.verifier;
      const reauthorizingCredentialId = gitlabStatesCache.get(state)?.credentialId;

      if (PLAYWRIGHT_TEST) {
        verifier = 'test-verifier';
      }

      if (!verifier) {

View on GitHub (pinned to d9bb2b0142)