{"record":{"id":"c2e995c6879e51eb","repo":"git-ecosystem/git-credential-manager","slug":"unknown-authentication-mode","errorCode":null,"errorMessage":"Unknown authentication mode","messagePattern":"Unknown authentication mode","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Atlassian.Bitbucket/BitbucketAuthentication.cs","lineNumber":145,"sourceCode":"            }\n\n            await AvaloniaUi.ShowViewAsync<CredentialsView>(viewModel, GetParentWindowHandle(), CancellationToken.None);\n\n            ThrowIfWindowCancelled(viewModel);\n\n            switch (viewModel.SelectedMode)\n            {\n                case AuthenticationModes.OAuth:\n                    return new CredentialsPromptResult(AuthenticationModes.OAuth);\n\n                case AuthenticationModes.Basic:\n                    return new CredentialsPromptResult(\n                        AuthenticationModes.Basic,\n                        new GitCredential(viewModel.UserName, viewModel.Password)\n                        );\n\n                default:\n                    throw new ArgumentOutOfRangeException(nameof(AuthenticationModes),\n                        \"Unknown authentication mode\", viewModel.SelectedMode.ToString());\n            }\n        }\n\n        private async Task<CredentialsPromptResult> GetCredentialsViaTtyAsync(Uri targetUri, string userName, AuthenticationModes modes)\n        {\n            ThrowIfTerminalPromptsDisabled();\n\n            switch (modes)\n            {\n                case AuthenticationModes.Basic:\n                    Context.Console.WriteLine($\"Enter Bitbucket credentials for '{targetUri}'...\");\n\n                    if (!string.IsNullOrWhiteSpace(userName))\n                    {\n                        // Don't need to prompt for the username if it has been specified already\n                        Context.Console.WriteLine($\"Username: {userName}\");\n                    }","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Atlassian.Bitbucket/BitbucketAuthentication.cs#L127-L163","documentation":"The Bitbucket UI credential prompt switch handles a fixed set of AuthenticationModes values; any mode selected outside the handled cases hits the default branch and throws ArgumentOutOfRangeException with message 'Unknown authentication mode'. This is an internal invariant: the UI should only ever offer supported modes.","triggerScenarios":"GetCredentialsAsync -> GetCredentialsViaUiAsync when viewModel.SelectedMode holds a mode value not present in the switch's case labels (e.g. an enum value added or combined flags passed through).","commonSituations":"Version mismatch between GCM components or plugins passing a new/combined AuthenticationModes value; manual construction of CredentialsPromptOptions with an unhandled mode.","solutions":["Ensure only single, supported modes (Basic, OAuth/Browser, Gcm) are included in the modes set passed to GetCredentialsAsync","Update Git Credential Manager to matching versions so UI helper and enum definitions agree","If custom-calling, avoid passing combined flags; pass one mode per prompt"],"exampleFix":"// before\nvar result = await auth.GetCredentialsAsync(uri, null, AuthenticationModes.Basic | AuthenticationModes.OAuth | (AuthenticationModes)0x100);\n// after\nvar result = await auth.GetCredentialsAsync(uri, null, AuthenticationModes.Basic | AuthenticationModes.OAuth);","handlingStrategy":"validation","validationCode":"var allowed = new[] { AuthenticationModes.Basic, AuthenticationModes.OAuth, AuthenticationModes.Browser };\nif (!allowed.Contains(mode)) throw new InvalidOperationException($\"Unsupported mode {mode}\");","typeGuard":"bool IsSupportedMode(AuthenticationModes m) => m is AuthenticationModes.Basic or AuthenticationModes.OAuth or AuthenticationModes.Browser;","tryCatchPattern":"try { await auth.GetCredentialsAsync(uri, user, modes); }\ncatch (ArgumentOutOfRangeException ex) { trace.Error(ex); return null; }","preventionTips":["Pass single enum values, not arbitrary flag combinations","Keep GCM and its UI helper on the same version","Only include modes the host provider documents as supported"],"tags":["argument-out-of-range","enum","authentication","ui-prompt"],"backgroundTag":"invalid-enum-value","analyzedSha":"e8ce762cd04b4100ae637b5fbf39ef9d0a96561e","analyzedAt":"2026-09-11T17:15:08.753Z","contentChangedAt":"2026-09-11T17:15:08.753Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}