{"record":{"id":"20e491ac9d27dcb0","repo":"Devolutions/UniGetUI","slug":"the-route-value-key-is-required","errorCode":null,"errorMessage":"The route value \"{key}\" is required.","messagePattern":"The route value \"(.+?)\" is required\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":400,"severity":"error","filePath":"src/UniGetUI.Interface.IpcApi/IpcServer.cs","lineNumber":1905,"sourceCode":"        }\n\n        private static IpcAppNavigateRequest BuildAppNavigateRequest(HttpRequest request)\n        {\n            return new IpcAppNavigateRequest\n            {\n                Page = GetRequiredQueryValue(request, \"page\"),\n                ManagerName = GetOptionalQueryValue(request, \"manager\"),\n                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","sourceCodeStart":1887,"sourceCodeEnd":1923,"githubUrl":"https://github.com/Devolutions/UniGetUI/blob/9b1d7d0eab91620fc15c86b36676532095936ae3/src/UniGetUI.Interface.IpcApi/IpcServer.cs#L1887-L1923","documentation":"Thrown by GetRequiredRouteValue when a required route segment is absent, not a string, or whitespace. Routes bind segments from the URL template; a missing/blank segment yields HTTP 400 via the InvalidOperationException catch in the handler.","triggerScenarios":"Requesting a templated route like {key}/... without supplying the segment, or with a blank value, or a non-string route binding.","commonSituations":"Mismatched URL template vs. client request; client omitted the path segment; routing misconfiguration so the value never binds.","solutions":["Include the non-empty {key} segment in the request URL exactly as the route template requires.","Verify the endpoint route template and align the client path construction.","For optional behavior, switch to a query parameter / GetOptionalQueryValue instead of a required route value."],"exampleFix":"// before: GET /v3/{key}/action with key missing -> HTTP 400\n// after:\nvar url = $\"/v3/{Uri.EscapeDataString(key)}/action?token={token}\";","handlingStrategy":"validation","validationCode":"// Client: assert the required route segment is non-empty.\nif (string.IsNullOrWhiteSpace(key)) throw new ArgumentException(\"route key required\");\nvar url = $\"/v3/{Uri.EscapeDataString(key)}/action?token={token}\";","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate required path segments client-side before constructing the URL.","Keep route templates and client URL builders in sync via a shared constant.","Use query parameters for optional values to avoid blank route segments."],"tags":["ipc","http-400","routing","route-value"],"backgroundTag":null,"analyzedSha":"9b1d7d0eab91620fc15c86b36676532095936ae3","analyzedAt":"2026-08-13T12:19:18.278Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}