{"record":{"id":"ce8df27133d675a2","repo":"git-ecosystem/git-credential-manager","slug":"must-specify-at-least-one-authenticationmodes","errorCode":null,"errorMessage":"Must specify at least one AuthenticationModes","messagePattern":"Must specify at least one AuthenticationModes","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Atlassian.Bitbucket/BitbucketAuthentication.cs","lineNumber":93,"sourceCode":"            ThrowIfUserInteractionDisabled();\n\n            // If we don't have a desktop session/GUI then we cannot offer OAuth since the only\n            // supported grant is authcode (i.e, using a web browser; device code is not supported).\n            if (!Context.SessionManager.IsDesktopSession)\n            {\n                modes = modes & ~AuthenticationModes.OAuth;\n            }\n\n            // If the only supported mode is OAuth then just return immediately\n            if (modes == AuthenticationModes.OAuth)\n            {\n                return new CredentialsPromptResult(AuthenticationModes.OAuth);\n            }\n\n            // We need at least one mode!\n            if (modes == AuthenticationModes.None)\n            {\n                throw new ArgumentException(@$\"Must specify at least one {nameof(AuthenticationModes)}\", nameof(modes));\n            }\n\n            // Shell out to the UI helper and show the Bitbucket u/p prompt\n            if (Context.Settings.IsGuiPromptsEnabled && Context.SessionManager.IsDesktopSession)\n            {\n                if (TryFindHelperCommand(out string helperCommand, out string args))\n                {\n                    return await GetCredentialsViaHelperAsync(targetUri, userName, modes, helperCommand, args);\n                }\n\n                return await GetCredentialsViaUiAsync(targetUri, userName, modes);\n            }\n\n            return await GetCredentialsViaTtyAsync(targetUri, userName, modes);\n        }\n\n        private async Task<CredentialsPromptResult> GetCredentialsViaUiAsync(\n            Uri targetUri, string userName, AuthenticationModes modes)","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Atlassian.Bitbucket/BitbucketAuthentication.cs#L75-L111","documentation":"BitbucketAuthentication.GetCredentialsAsync validates the requested set of authentication modes before showing any prompt. If the caller passes AuthenticationModes.None (no supported auth mode), the library cannot proceed and throws ArgumentException naming the modes parameter. This is a programming/configuration error, not a runtime user action.","triggerScenarios":"Calling GetCredentialsAsync (directly or via BitbucketHostProvider.GetCredentialAsync) when GetSupportedAuthenticationModesAsync resolved to AuthenticationModes.None — e.g. an unrecognized host configuration that disables Basic, OAuth, and GCM modes.","commonSituations":"Custom host provider configurations, settings that disable all auth modes (e.g. both oauth and basic disabled via GCM_* settings), or calling the authentication API directly with modes: AuthenticationModes.None.","solutions":["Check the modes argument passed to GetCredentialsAsync; ensure at least one AuthenticationModes flag (Basic, OAuth, Browser, Gcm) is set","Inspect the settings controlling GetSupportedAuthenticationModesAsync (e.g. GCM_BITBUCKET_AUTHMODES / host provider config) and enable a valid mode","If computing modes dynamically, guard with `if ((modes & AuthenticationModes.None) != 0 || modes == AuthenticationModes.None)` before calling"],"exampleFix":"// before\nvar modes = AuthenticationModes.None;\nvar cred = await auth.GetCredentialsAsync(uri, userName, modes);\n// after\nvar modes = AuthenticationModes.Basic | AuthenticationModes.OAuth;\nvar cred = await auth.GetCredentialsAsync(uri, userName, modes);","handlingStrategy":"validation","validationCode":"if (modes == AuthenticationModes.None)\n    throw new ArgumentException(\"At least one auth mode required\");\nvar cred = await auth.GetCredentialsAsync(uri, userName, modes);","typeGuard":"bool HasAnyMode(AuthenticationModes m) => m != AuthenticationModes.None;","tryCatchPattern":"try { await auth.GetCredentialsAsync(uri, user, modes); }\ncatch (ArgumentException ex) when (ex.ParamName == \"modes\") { /* configure a valid mode and retry */ }","preventionTips":["Never pass AuthenticationModes.None to credential APIs","Derive modes from the host provider's GetSupportedAuthenticationModesAsync, not hard-coded values","Add a unit test asserting non-None modes for each host config"],"tags":["argument-validation","authentication","bitbucket","csharp"],"backgroundTag":"missing-required-argument","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"}