theonedev/onedev · error · IllegalArgumentException
build number has to be specified
Error message
build number has to be specified
What it means
MarkdownReportDownloadResource.newResourceResponse() requires a build number; when params.get(PARAM_BUILD).toOptionalLong() yields null it throws IllegalArgumentException 'build number has to be specified'. The resource cannot locate a report without knowing which build produced it.
Source
Thrown at server-plugin/server-plugin-report-markdown/src/main/java/io/onedev/server/plugin/report/markdown/MarkdownReportDownloadResource.java:46
private static final long serialVersionUID = 1L;
private static final String PARAM_PROJECT = "project";
private static final String PARAM_BUILD = "build";
private static final String PARAM_REPORT = "report";
@Override
protected ResourceResponse newResourceResponse(Attributes attributes) {
PageParameters params = attributes.getParameters();
String projectPath = params.get(PARAM_PROJECT).toString();
Project project = OneDev.getInstance(ProjectService.class).findByPath(projectPath);
Long buildNumber = params.get(PARAM_BUILD).toOptionalLong();
if (buildNumber == null)
throw new IllegalArgumentException("build number has to be specified");
Build build = OneDev.getInstance(BuildService.class).find(project, buildNumber);
if (build == null) {
String message = String.format("Unable to find build (project: %s, build number: %d)",
project.getPath(), buildNumber);
throw new EntityNotFoundException(message);
}
String reportName = params.get(PARAM_REPORT).toOptionalString();
if (reportName == null)
throw new IllegalArgumentException("Markdown report name has to be specified");
if (reportName.contains(".."))
throw new ExplicitException("Invalid request path");
if (!SecurityUtils.canAccessReport(build, reportName))
throw new UnauthorizedException();View on GitHub (pinned to d44925c47c)
Solutions
- Include the build number parameter in the resource URL
- Fix the URL template so the build variable is populated before requesting
- Validate the build number client-side before constructing the URL
Example fix
// before GET /~resources/markdown-report/proj//report/coverage // after GET /~resources/markdown-report/proj/87/report/coverage
Defensive patterns
Strategy: validation
Validate before calling
if (buildNumber == null || isNaN(Number(buildNumber))) throw new Error('build number has to be specified'); Type guard
function hasBuildNumber(params) { return params.get('build') != null && !isNaN(Number(params.get('build'))); } Try / catch
try { fetch(url); } catch (IllegalArgumentException e) { // supply build param and retry } Prevention
- Interpolate build number from CI context before building the URL
- Assert all required query params are non-empty in link builders
- Fail fast client-side when template variables are unset
When it happens
Trigger: GET on the markdown report download resource omitting the build parameter (or supplying a non-numeric value so toOptionalLong returns null).
Common situations: Hand-built URLs missing the build parameter; API clients templating the URL with an empty/unset build variable.
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
- File path has to be specified
- Markdown report name has to be specified
- Missing query params:
- Unable to find build (project: %s, build number: %d)
- Invalid request path
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/16889d30c96e1b11.
Report an issue: GitHub.