{"record":{"id":"cf7bd617237cd17e","repo":"Devolutions/UniGetUI","slug":"the-query-value-key-is-required","errorCode":null,"errorMessage":"The query value \"{key}\" is required.","messagePattern":"The query value \"(.+?)\" is required\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":400,"severity":"error","filePath":"src/UniGetUI.Interface.IpcApi/IpcServer.cs","lineNumber":1913,"sourceCode":"                HelpAttachment = GetOptionalQueryValue(request, \"helpAttachment\"),\n            };\n        }\n\n        private static string GetRequiredRouteValue(HttpContext context, string key)\n        {\n            return context.Request.RouteValues.TryGetValue(key, out object? value)\n                && value is string stringValue\n                && !string.IsNullOrWhiteSpace(stringValue)\n                ? stringValue\n                : throw new InvalidOperationException($\"The route value \\\"{key}\\\" is required.\");\n        }\n\n        private static string GetRequiredQueryValue(HttpContext context, string key)\n        {\n            string? value = context.Request.Query[key].ToString();\n            return !string.IsNullOrWhiteSpace(value)\n                ? value\n                : throw new InvalidOperationException($\"The query value \\\"{key}\\\" is required.\");\n        }\n\n        private static string GetRequiredQueryValue(HttpRequest request, string key)\n        {\n            string? value = request.Query[key].ToString();\n            return !string.IsNullOrWhiteSpace(value)\n                ? value\n                : throw new InvalidOperationException($\"The query value \\\"{key}\\\" is required.\");\n        }\n\n        private static string? GetOptionalQueryValue(HttpRequest request, string key)\n        {\n            if (!request.Query.TryGetValue(key, out var value))\n            {\n                return null;\n            }\n\n            string? stringValue = value.ToString();","sourceCodeStart":1895,"sourceCodeEnd":1931,"githubUrl":"https://github.com/Devolutions/UniGetUI/blob/9b1d7d0eab91620fc15c86b36676532095936ae3/src/UniGetUI.Interface.IpcApi/IpcServer.cs#L1895-L1931","documentation":"Thrown by the GetRequiredQueryValue(HttpContext, key) overload when the query string key is missing or whitespace. Used inside HttpContext-based builders (e.g. the install/upgrade request path). Results in HTTP 400 from the handler's InvalidOperationException catch.","triggerScenarios":"Calling a package-action or command endpoint that requires the given query key without supplying it (e.g. omitting ?packageId=...).","commonSituations":"Client builds the query string conditionally and drops the key; wrong query parameter name; URL-encoding bug that blanks the value.","solutions":["Append the required key with a non-empty value: ?packageId=<value>.","Centralize query construction so required keys are always included.","If the value is genuinely optional, ensure the endpoint uses GetOptionalQueryValue instead."],"exampleFix":"// before: GET /v3/action?token=... (missing packageId) -> HTTP 400\n// after:\nvar qs = $\"?token={token}&packageId={Uri.EscapeDataString(packageId)}\";","handlingStrategy":"validation","validationCode":"// Client: build the query with guaranteed required keys.\nif (string.IsNullOrWhiteSpace(packageId)) throw new ArgumentException(\"packageId required\");\nvar qs = $\"?token={token}&packageId={Uri.EscapeDataString(packageId)}\";","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-validate required query keys before sending the request.","Use a query-builder helper that rejects null/whitespace required keys.","Match query parameter names to the server's GetRequiredQueryValue keys exactly."],"tags":["ipc","http-400","query-string","validation"],"backgroundTag":null,"analyzedSha":"9b1d7d0eab91620fc15c86b36676532095936ae3","analyzedAt":"2026-08-13T12:19:18.278Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}