{"record":{"id":"71bf2770ced19a11","repo":"Devolutions/UniGetUI","slug":"the-status-parameter-must-be-either-keep-or-delete","errorCode":null,"errorMessage":"The status parameter must be either keep or delete.","messagePattern":"The status parameter must be either keep or delete\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/UniGetUI.Interface.IpcApi/IpcDesktopShortcutsApi.cs","lineNumber":58,"sourceCode":"        return allShortcuts\n            .OrderBy(path => System.IO.Path.GetFileName(path), StringComparer.OrdinalIgnoreCase)\n            .ThenBy(path => path, StringComparer.OrdinalIgnoreCase)\n            .Select(path => ToShortcutInfo(path, trackedShortcuts))\n            .ToArray();\n    }\n\n    public static IpcDesktopShortcutOperationResult SetShortcut(\n        IpcDesktopShortcutRequest request\n    )\n    {\n        string shortcutPath = NormalizeShortcutPath(request.Path);\n        string shortcutStatus = request.Status?.Trim().ToLowerInvariant() ?? \"\";\n\n        DesktopShortcutsDatabase.Status status = shortcutStatus switch\n        {\n            \"delete\" => DesktopShortcutsDatabase.Status.Delete,\n            \"keep\" => DesktopShortcutsDatabase.Status.Maintain,\n            _ => throw new InvalidOperationException(\n                \"The status parameter must be either keep or delete.\"\n            ),\n        };\n\n        DesktopShortcutsDatabase.AddToDatabase(shortcutPath, status);\n        DesktopShortcutsDatabase.RemoveFromUnknownShortcuts(shortcutPath);\n\n        if (status is DesktopShortcutsDatabase.Status.Delete && File.Exists(shortcutPath))\n        {\n            DesktopShortcutsDatabase.DeleteFromDisk(shortcutPath);\n        }\n\n        return new IpcDesktopShortcutOperationResult\n        {\n            Command = \"set-desktop-shortcut\",\n            Shortcut = ToShortcutInfo(shortcutPath),\n        };\n    }","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/Devolutions/UniGetUI/blob/9b1d7d0eab91620fc15c86b36676532095936ae3/src/UniGetUI.Interface.IpcApi/IpcDesktopShortcutsApi.cs#L40-L76","documentation":"Thrown by IpcDesktopShortcutsApi.SetShortcut when request.Status (trimmed, lowercased) is neither 'keep' nor 'delete'. These are the only two statuses the set-shortcut operation accepts because they map directly to DesktopShortcutsDatabase.Status.Maintain and .Delete.","triggerScenarios":"POSTing to the set-desktop-shortcut endpoint with a Status of 'unknown', 'remove', 'always', 'maintain' (the code wants 'keep'), or null. The switch has no default-accept; anything off-list throws.","commonSituations":"Using 'maintain' (the internal enum name) instead of the API token 'keep'. Sending 'unknown' (which the info endpoint can return) back as a set action. Passing an empty or null Status expecting a default.","solutions":["Send Status 'keep' to maintain the shortcut or 'delete' to remove it.","Do not reuse a status value read from the info endpoint (e.g. 'unknown') directly in a set request.","Use the reset-shortcut endpoint if you want to return a shortcut to unknown/pending-review."],"exampleFix":"// before\n{ \"path\": \"...\", \"status\": \"maintain\" }\n// after\n{ \"path\": \"...\", \"status\": \"keep\" }","handlingStrategy":"validation","validationCode":"static bool IsValidShortcutStatus(string? s) =>\n    s?.Trim().ToLowerInvariant() is \"keep\" or \"delete\";","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a fixed keep/delete selector in the UI, not free text.","Never echo an info-endpoint status ('unknown') into a set request."],"tags":["ipc","desktop-shortcuts","input-validation","enum"],"backgroundTag":null,"analyzedSha":"9b1d7d0eab91620fc15c86b36676532095936ae3","analyzedAt":"2026-08-13T12:19:18.278Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}