{"record":{"id":"83c20eb62335b54c","repo":"theonedev/onedev","slug":"missing-query-params","errorCode":null,"errorMessage":"Missing query params: ","messagePattern":"Missing query params: ","errorType":"validation","errorClass":"NotAcceptableException","httpStatus":406,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/rest/ParamCheckFilter.java","lineNumber":53,"sourceCode":"\t\tfor (Parameter param: resourceInfo.getResourceMethod().getParameters()) {\n\t\t\tQueryParam queryParam = param.getAnnotation(QueryParam.class);\n\t\t\tif (queryParam != null) {\n\t\t\t\tdefinedQueryParams.add(queryParam.value());\n\t\t\t\tif (isRequired(param)) \n\t\t\t\t\trequiredQueryParams.add(queryParam.value());\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (resourceInfo.getResourceClass() != TriggerJobResource.class) {\n\t\t\tSet<String> suppliedQueryParams = new HashSet<>(uriInfo.getQueryParameters().keySet());\n\t\t\tsuppliedQueryParams.removeAll(definedQueryParams);\n\t\t\tif (!suppliedQueryParams.isEmpty()) \n\t\t\t\tthrow new NotAcceptableException(\"Unexpected query params: \" + suppliedQueryParams);\n\t\t}\n\n\t\trequiredQueryParams.removeAll(uriInfo.getQueryParameters().keySet());\n\t\tif (!requiredQueryParams.isEmpty()) \n\t\t\tthrow new NotAcceptableException(\"Missing query params: \" + requiredQueryParams);\n\t}\n\n\tpublic static boolean isRequired(Parameter param) {\n\t\treturn param.getType().isPrimitive() \n\t\t\t\t|| param.getAnnotation(NotNull.class) != null \n\t\t\t\t|| param.getAnnotation(NotEmpty.class) != null \n\t\t\t\t|| param.getAnnotation(Size.class)!=null && param.getAnnotation(Size.class).min()>0;\n\t}\n\t\n}\n","sourceCodeStart":35,"sourceCodeEnd":64,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/rest/ParamCheckFilter.java#L35-L64","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add the missing query parameter(s) named in the message to the request URL","Provide a valid non-empty value — empty values may still fail validation","Check the endpoint's resource class/docs for the parameter's expected type and format","If the param was previously optional, align client with the server version"],"exampleFix":"// before\nGET /api/query/projects   // 'query' is @NotEmpty @QueryParam\n// after\nGET /api/query/projects?query=state is Open","handlingStrategy":"validation","validationCode":"const required = ['query']; // required @QueryParams of the target endpoint\nconst missing = required.filter(p => !new URL(requestUrl).searchParams.get(p));\nif (missing.length) throw new Error(`Missing query params: ${missing}`);","typeGuard":null,"tryCatchPattern":"try {\n  const res = await fetch(url);\n  if (res.status === 406) {\n    const msg = await res.text();\n    const missing = msg.match(/Missing query params: \\[([^\\]]+)\\]/)?.[1];\n    throw new Error(`Add required params: ${missing}`);\n  }\n} catch (e) { /* handle */ }","preventionTips":["Check the resource method for @NotNull/@NotEmpty/@Size-annotated @QueryParams before calling","Validate all required params are non-empty before sending","Keep client code in sync with the OneDev server version in use"],"tags":["rest","query-params","http-406","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}