git-ecosystem/git-credential-manager · error · ArgumentOutOfRangeException
Unknown authentication mode
Error message
Unknown authentication mode
What it means
After the dialog returns, ExecuteAsync switches on viewModel.SelectedMode and writes the credential result. An unrecognized mode falls into the default case, throwing ArgumentOutOfRangeException("Unknown authentication mode") — an internal invariant violation meaning the AuthenticationModes enum gained a value the command does not handle.
Solutions
- Upgrade or reinstall git-credential-manager so the UI and command code are from the same version.
- If you build from source, add a case for the new AuthenticationModes value in CredentialsCommand.ExecuteAsync.
- Report a bug with trace2 logs if it occurs on an unmodified release build.
Example fix
// before
default:
throw new ArgumentOutOfRangeException(nameof(AuthenticationModes), "Unknown authentication mode", viewModel.SelectedMode.ToString());
// after: handle the new mode explicitly
case AuthenticationModes.BearerToken:
WriteResult(new Dictionary<string, string> { ["password"] = viewModel.Token });
break; Defensive patterns
Strategy: try-catch
Type guard
Enum.IsDefined(typeof(AuthenticationModes), viewModel.SelectedMode)
Try / catch
try { await command.ExecuteAsync(input); } catch (ArgumentOutOfRangeException ex) when (ex.Message.Contains("Unknown authentication mode")) { /* upgrade GCM or report bug with trace2 logs */ } Prevention
- Keep UI and CredentialsCommand builds version-aligned
- When extending AuthenticationModes, update the switch in ExecuteAsync in the same change
- Pin a single GCM installation rather than mixing distro and manual installs
When it happens
Trigger: viewModel.SelectedMode contains a value not covered by the handled AuthenticationModes cases (OAuth, Basic, etc.) — usually only possible when the enum and the switch are out of sync after a code change, or corrupted state.
Common situations: Developers adding a new AuthenticationModes member without updating CredentialsCommand's switch; users on mismatched GCM builds/plugins; bespoke forks extending the enum.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Bitbucket DC OAuth Client ID must be defined
- Bitbucket DC OAuth Client Secret must be defined
- RemoteUri must be defined to generate Bitbucket DC OAuth2…
- RemoteUri must be defined to generate Bitbucket DC OAuth2…
- User cancelled dialog.
AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11).
Data as JSON: /api/errors/7440287eef8771f8.
Report an issue: GitHub.
Appendix: source
Thrown at src/Atlassian.Bitbucket/UI/Commands/CredentialsCommand.cs:69
{
case AuthenticationModes.OAuth:
WriteResult(new Dictionary<string, string>
{
["mode"] = "oauth"
});
break;
case AuthenticationModes.Basic:
WriteResult(new Dictionary<string, string>
{
["mode"] = "basic",
["username"] = viewModel.UserName,
["password"] = viewModel.Password,
});
break;
default:
throw new ArgumentOutOfRangeException(nameof(AuthenticationModes),
"Unknown authentication mode", viewModel.SelectedMode.ToString());
}
return 0;
}
protected abstract Task ShowAsync(CredentialsViewModel viewModel, CancellationToken ct);
}
}
View on GitHub (pinned to e8ce762cd0)