Devolutions/UniGetUI · error · InvalidOperationException
The query value "{key}" is required.
Error message
The query value "{key}" is required. What it means
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.
Source
Thrown at src/UniGetUI.Interface.IpcApi/IpcServer.cs:1913
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.");
}
private static string? GetOptionalQueryValue(HttpRequest request, string key)
{
if (!request.Query.TryGetValue(key, out var value))
{
return null;
}
string? stringValue = value.ToString();View on GitHub (pinned to 9b1d7d0eab)
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.
Example fix
// before: GET /v3/action?token=... (missing packageId) -> HTTP 400
// after:
var qs = $"?token={token}&packageId={Uri.EscapeDataString(packageId)}"; Defensive patterns
Strategy: validation
Validate before calling
// Client: build the query with guaranteed required keys.
if (string.IsNullOrWhiteSpace(packageId)) throw new ArgumentException("packageId required");
var qs = $"?token={token}&packageId={Uri.EscapeDataString(packageId)}"; Prevention
- 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.
When it happens
Trigger: Calling a package-action or command endpoint that requires the given query key without supplying it (e.g. omitting ?packageId=...).
Common situations: Client builds the query string conditionally and drops the key; wrong query parameter name; URL-encoding bug that blanks the value.
Related errors
- Unsupported page \"{page}\". Supported pages: {string.Join("
- The cloud backup \"{key}\" was not found.
- The backup key is required.
- Exactly one of content or path must be supplied when importi
- The manager action "{action}" requires confirm=true.
AI-assisted analysis of Devolutions/UniGetUI@9b1d7d0eab (2026-08-13).
Data as JSON: /api/errors/cf7bd617237cd17e.
Report an issue: GitHub.