{"record":{"id":"9867d650bf1c1c07","repo":"Devolutions/UniGetUI","slug":"the-action-field-is-required","errorCode":null,"errorMessage":"The action field is required.","messagePattern":"The action field is required\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/UniGetUI.Interface.IpcApi/IpcManagerMaintenanceApi.cs","lineNumber":119,"sourceCode":"        Settings.RemoveDictionaryKey<string, string>(Settings.K.ManagerPaths, manager.Name);\n        await ReloadManagerAsync(manager);\n        return Success(\n            \"clear-manager-executable\",\n            manager,\n            \"clear-executable\",\n            \"completed\",\n            $\"Cleared the custom executable override for {manager.DisplayName}.\"\n        );\n    }\n\n    public static async Task<IpcManagerMaintenanceActionResult> RunActionAsync(\n        IpcManagerMaintenanceRequest request\n    )\n    {\n        ArgumentNullException.ThrowIfNull(request);\n        var manager = IpcManagerSettingsApi.ResolveManager(request.ManagerName);\n        string action = request.Action?.Trim().ToLowerInvariant()\n            ?? throw new InvalidOperationException(\"The action field is required.\");\n\n        switch (action)\n        {\n            case \"repair-winget\":\n                EnsureConfirmed(request, action);\n                EnsureManager(manager, \"WinGet\");\n                EnsureWindowsOnly(action);\n                await RunWindowsProcessAsync(\n                    CoreData.PowerShell5,\n                    \"-ExecutionPolicy Bypass -NoLogo -NoProfile -Command \\\"& {\"\n                    + \"cmd.exe /C \\\"\\\"rmdir /Q /S `\\\"%temp%\\\\WinGet`\\\"\\\"\\\"; \"\n                    + \"cmd.exe /C \\\"\\\"`\\\"%localappdata%\\\\Microsoft\\\\WindowsApps\\\\winget.exe`\\\" source reset --force\\\"\\\"; \"\n                    + \"taskkill /im winget.exe /f; \"\n                    + \"taskkill /im WindowsPackageManagerServer.exe /f; \"\n                    + \"Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force; \"\n                    + \"Install-Module Microsoft.WinGet.Client -Force -AllowClobber; \"\n                    + \"Import-Module Microsoft.WinGet.Client; \"\n                    + \"Repair-WinGetPackageManager -Force -Latest; \"","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/Devolutions/UniGetUI/blob/9b1d7d0eab91620fc15c86b36676532095936ae3/src/UniGetUI.Interface.IpcApi/IpcManagerMaintenanceApi.cs#L101-L137","documentation":"Thrown by IpcManagerMaintenanceApi.RunActionAsync when request.Action is null (the ?? coalesce fires). Note this only triggers on a truly null Action; a non-null but unrecognized action falls through to the default arm (error 39). The Action field selects which maintenance procedure to run.","triggerScenarios":"POSTing to the manager maintenance action endpoint with the Action field omitted or explicitly null. An empty/whitespace Action is trimmed to empty string, which is non-null, so it reaches the switch and falls to error 39 instead.","commonSituations":"A client library that omits nullable fields rather than sending them. A malformed JSON body missing the action key. A UI binding that did not set the selected action.","solutions":["Include an Action field with one of the supported maintenance actions (e.g. repair-winget, install-scoop, uninstall-scoop, cleanup-scoop).","If the body is being built dynamically, default Action to a concrete value rather than leaving it null.","Consult ToMaintenanceInfo/GetMaintenanceInfo for the supportedActions list for the target manager."],"exampleFix":"// before\n{ \"managerName\": \"winget\", \"action\": null }\n// after\n{ \"managerName\": \"winget\", \"action\": \"repair-winget\", \"confirm\": true }","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(request.Action)) { /* require the user to choose an action */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bind the action field to a non-null enum/selector in the client DTO.","Read supportedActions from GetMaintenanceInfo to populate the selector."],"tags":["ipc","manager-maintenance","input-validation","missing-argument"],"backgroundTag":null,"analyzedSha":"9b1d7d0eab91620fc15c86b36676532095936ae3","analyzedAt":"2026-08-13T12:19:18.278Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}