{"record":{"id":"53302553db6d0950","repo":"git-ecosystem/git-credential-manager","slug":"missing-or-invalid-interaction-mode-in-response","errorCode":null,"errorMessage":"Missing or invalid interaction_mode in response","messagePattern":"Missing or invalid interaction_mode in response","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"error","filePath":"src/Core/Authentication/Entra/EntraAuthentication.PublicClient.cs","lineNumber":119,"sourceCode":"        // Show auth mode prompt\n        if (Context.Settings.IsGuiPromptsEnabled && Context.SessionManager.IsDesktopSession)\n        {\n            if (TryFindHelperCommand(out string command, out string args))\n            {\n                var availableNames = available.Select(m => m.ToString().ToLowerInvariant());\n\n                var sb = new StringBuilder(args);\n                sb.Append(\"select-interaction-mode\");\n                sb.AppendFormat(\" --available {0}\", QuoteCmdArg(string.Join(',', availableNames)));\n\n                IDictionary<string, string> result = await InvokeHelperAsync(command, sb.ToString());\n                if (result.TryGetValue(\"interaction_mode\", out string str) &&\n                    Enum.TryParse(str, ignoreCase: true, out InteractionMode choice))\n                {\n                    return choice;\n                }\n\n                throw new Trace2Exception(Context.Trace2, \"Missing or invalid interaction_mode in response\");\n            }\n\n            // TODO: show prompt in-proc\n        }\n\n        // Show prompt in tty\n        var prompt = TerminalPrompts.CreateSelection<InteractionMode>()\n            .Title(\"Select an authentication flow\")\n            .AddChoices(available, m => m.GetDisplayName());\n        return await prompt.ShowAsync(Context.Console, ct);\n    }\n\n    public async Task<IReadOnlyList<IEntraAccount>> GetUserAccountsAsync(CancellationToken ct = default)\n    {\n        IPublicClientApplication app = GetPublicAppBuilder(out _).Build();\n        await RegisterCacheAsync(app);\n\n        IEnumerable<IAccount> accounts = await app.GetAccountsAsync();","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Authentication/Entra/EntraAuthentication.PublicClient.cs#L101-L137","documentation":"When GCM needs to ask how the user wants to authenticate, it shows a prompt whose response dictionary should include an 'interaction_mode' key parseable as an InteractionMode enum. This throws when the key is absent or its value cannot be parsed, so the desired interaction mode is unknown.","triggerScenarios":"GetInteractionModeAsync reads a prompt response via TryGetValue(\"interaction_mode\", out str) and Enum.TryParse(str, ignoreCase: true, out InteractionMode choice); if either fails, the Trace2Exception is thrown. Only reached in the non-tty/prompt path (not the tty branch).","commonSituations":"A custom/overridden prompt or helper returns a response missing interaction_mode; a typo'd or new mode string not present in the current InteractionMode enum; version mismatch where the prompt emits a newer mode name than this GCM build understands.","solutions":["Ensure the prompt/helper response includes interaction_mode with a supported value (e.g. OAuth, Browser, Device, Basic)","Fix spelling/casing of the value and verify it exists in the current InteractionMode enum","Upgrade GCM if the mode name is from a newer version","Set the interaction mode explicitly via configuration (GCM_INTERACTIVE / credential.interactive) so the prompt path isn't relied on"],"exampleFix":"// before (helper response)\n\"mode=Browser\"\n// after\n\"interaction_mode=Browser\"","handlingStrategy":"try-catch","validationCode":"if (!Enum.TryParse<InteractionMode>(modeString, ignoreCase: true, out _))\n    throw new ArgumentException($\"'{modeString}' is not a valid InteractionMode.\");","typeGuard":"bool TryGetInteractionMode(IDictionary<string,string> resp, out InteractionMode mode) {\n    mode = default;\n    return resp.TryGetValue(\"interaction_mode\", out var s) && Enum.TryParse(s, ignoreCase: true, out mode) && Enum.IsDefined(mode);\n}","tryCatchPattern":"try { /* entra auth */ }\ncatch (Trace2Exception ex) when (ex.Message.Contains(\"interaction_mode\")) { /* fix prompt/helper response or set mode via config */ }","preventionTips":["Set interaction mode explicitly via GCM configuration to bypass prompts","Keep custom prompt implementations emitting the exact 'interaction_mode' key","Validate mode names against the GCM version in use"],"tags":["interaction-mode","enum","prompt","entra"],"backgroundTag":"unexpected-response-shape","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"}