Devolutions/UniGetUI · error · InvalidOperationException

The route value "{key}" is required.

Error message

The route value "{key}" is required.

What it means

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.

Source

Thrown at src/UniGetUI.Interface.IpcApi/IpcServer.cs:1905

        }

        private static IpcAppNavigateRequest BuildAppNavigateRequest(HttpRequest request)
        {
            return new IpcAppNavigateRequest
            {
                Page = GetRequiredQueryValue(request, "page"),
                ManagerName = GetOptionalQueryValue(request, "manager"),
                HelpAttachment = GetOptionalQueryValue(request, "helpAttachment"),
            };
        }

        private static string GetRequiredRouteValue(HttpContext context, string key)
        {
            return context.Request.RouteValues.TryGetValue(key, out object? value)
                && value is string stringValue
                && !string.IsNullOrWhiteSpace(stringValue)
                ? stringValue
                : throw new InvalidOperationException($"The route value \"{key}\" is required.");
        }

        private static string GetRequiredQueryValue(HttpContext context, string key)
        {
            string? value = context.Request.Query[key].ToString();
            return !string.IsNullOrWhiteSpace(value)
                ? value
                : throw new InvalidOperationException($"The query value \"{key}\" is required.");
        }

        private static string GetRequiredQueryValue(HttpRequest request, string key)
        {
            string? value = request.Query[key].ToString();
            return !string.IsNullOrWhiteSpace(value)
                ? value
                : throw new InvalidOperationException($"The query value \"{key}\" is required.");
        }

View on GitHub (pinned to 9b1d7d0eab)

Solutions

  1. Include the non-empty {key} segment in the request URL exactly as the route template requires.
  2. Verify the endpoint route template and align the client path construction.
  3. For optional behavior, switch to a query parameter / GetOptionalQueryValue instead of a required route value.

Example fix

// before: GET /v3/{key}/action with key missing -> HTTP 400
// after:
var url = $"/v3/{Uri.EscapeDataString(key)}/action?token={token}";
Defensive patterns

Strategy: validation

Validate before calling

// Client: assert the required route segment is non-empty.
if (string.IsNullOrWhiteSpace(key)) throw new ArgumentException("route key required");
var url = $"/v3/{Uri.EscapeDataString(key)}/action?token={token}";

Prevention

When it happens

Trigger: Requesting a templated route like {key}/... without supplying the segment, or with a blank value, or a non-string route binding.

Common situations: Mismatched URL template vs. client request; client omitted the path segment; routing misconfiguration so the value never binds.

Related errors


AI-assisted analysis of Devolutions/UniGetUI@9b1d7d0eab (2026-08-13). Data as JSON: /api/errors/20e491ac9d27dcb0. Report an issue: GitHub.