theonedev/onedev · error · NotAcceptableException

Missing query params:

Error message

Missing query params: 

What it means

ParamCheckFilter checks that every @QueryParam on the target resource method marked required (primitive type, @NotNull, @NotEmpty, or @Size(min>0)) is present in the request. If a required query parameter is absent, it throws NotAcceptableException (HTTP 406) listing the missing names before the resource method runs.

Solutions

  1. Add the missing query parameter(s) named in the message to the request URL
  2. Provide a valid non-empty value — empty values may still fail validation
  3. Check the endpoint's resource class/docs for the parameter's expected type and format
  4. If the param was previously optional, align client with the server version

Example fix

// before
GET /api/query/projects   // 'query' is @NotEmpty @QueryParam
// after
GET /api/query/projects?query=state is Open
Defensive patterns

Strategy: validation

Validate before calling

const required = ['query']; // required @QueryParams of the target endpoint
const missing = required.filter(p => !new URL(requestUrl).searchParams.get(p));
if (missing.length) throw new Error(`Missing query params: ${missing}`);

Try / catch

try {
  const res = await fetch(url);
  if (res.status === 406) {
    const msg = await res.text();
    const missing = msg.match(/Missing query params: \[([^\]]+)\]/)?.[1];
    throw new Error(`Add required params: ${missing}`);
  }
} catch (e) { /* handle */ }

Prevention

When it happens

Trigger: Omitting a query parameter the endpoint declares as required — e.g. calling a search endpoint that declares @QueryParam("query") @NotEmpty String query without ?query=... The filter throws when requiredQueryParams minus supplied params is non-empty.

Common situations: Client written against an older API version where the param was optional; hand-built URLs where the param was never included; client library sending the param only under a flag; Postman/Swagger calls with an empty param field.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/83c20eb62335b54c. Report an issue: GitHub.

Appendix: source

Thrown at server-core/src/main/java/io/onedev/server/rest/ParamCheckFilter.java:53

		for (Parameter param: resourceInfo.getResourceMethod().getParameters()) {
			QueryParam queryParam = param.getAnnotation(QueryParam.class);
			if (queryParam != null) {
				definedQueryParams.add(queryParam.value());
				if (isRequired(param)) 
					requiredQueryParams.add(queryParam.value());
			}
		}
		
		if (resourceInfo.getResourceClass() != TriggerJobResource.class) {
			Set<String> suppliedQueryParams = new HashSet<>(uriInfo.getQueryParameters().keySet());
			suppliedQueryParams.removeAll(definedQueryParams);
			if (!suppliedQueryParams.isEmpty()) 
				throw new NotAcceptableException("Unexpected query params: " + suppliedQueryParams);
		}

		requiredQueryParams.removeAll(uriInfo.getQueryParameters().keySet());
		if (!requiredQueryParams.isEmpty()) 
			throw new NotAcceptableException("Missing query params: " + requiredQueryParams);
	}

	public static boolean isRequired(Parameter param) {
		return param.getType().isPrimitive() 
				|| param.getAnnotation(NotNull.class) != null 
				|| param.getAnnotation(NotEmpty.class) != null 
				|| param.getAnnotation(Size.class)!=null && param.getAnnotation(Size.class).min()>0;
	}
	
}

View on GitHub (pinned to d44925c47c)