theonedev/onedev · error · NotAcceptableException

Unexpected query params:

Error message

Unexpected query params: 

What it means

OneDev's ParamCheckFilter (a JAX-RS container request filter) rejects REST API calls whose query string contains parameters not declared via @QueryParam on the target resource method. This is an intentional strictness guard: unknown query params surface immediately as HTTP 406 NotAcceptableException instead of being silently ignored. Only the TriggerJobResource endpoint is exempt.

Source

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

	
	@Override
	public void filter(ContainerRequestContext requestContext) throws IOException {
		Set<String> definedQueryParams = new HashSet<>();
		Set<String> requiredQueryParams = new HashSet<>();
		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)

Solutions

  1. Remove the unknown query parameter(s) named in the message from the request URL
  2. Check the OneDev REST API docs (or the resource class source) for the exact @QueryParam names the endpoint defines
  3. Fix typos in parameter names (the set in the message lists the offending names)
  4. If a parameter used to work, verify server version — the endpoint signature may have changed between versions

Example fix

// before
GET /api/projects?name=app&pageSize=10   // endpoint has no pageSize @QueryParam
// after
GET /api/projects?name=app               // or use the endpoint's actual paging param
Defensive patterns

Strategy: validation

Validate before calling

const url = new URL(requestUrl);
const allowed = ['name','offset']; // @QueryParam names from endpoint docs/source
const unknown = [...url.searchParams.keys()].filter(k => !allowed.includes(k));
if (unknown.length) throw new Error(`Unexpected query params: ${unknown}`);

Try / catch

try {
  const res = await fetch(url);
  if (res.status === 406) {
    const msg = await res.text();
    const unknown = msg.match(/Unexpected query params: \[([^\]]+)\]/)?.[1];
    // strip the offending params and retry
  }
} catch (e) { /* handle network error */ }

Prevention

When it happens

Trigger: Calling any OneDev REST resource (other than TriggerJobResource) with a query parameter the invoked method does not define — e.g. appending ?page=2 to an endpoint with no such @QueryParam, or a typo like ?projectID= instead of ?projectId=. The filter throws when suppliedQueryParams minus definedQueryParams is non-empty.

Common situations: Reusing a query string copied from a different endpoint's docs; adding params supported in a different OneDev version; typo'd parameter names; generic HTTP clients appending defaults like ?format=json the endpoint never defined.

Understand the failure class

Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.

Related errors


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