theonedev/onedev · error · NotFoundException

Code problem report not found:

Error message

Code problem report not found: 

What it means

GET /get-build-code-problems throws NotFoundException ('Code problem report not found: {name}') when ProblemReport.readFrom(build, reportName) returns null - no problem report with that name exists on the specified build. Access checks pass; the report itself is simply absent.

Source

Thrown at server-core/src/main/java/io/onedev/server/ai/TodResource.java:883

    @Path("/get-build-code-problems")
    @GET
    public List<Map<String, Object>> getBuildCodeProblems(
                @QueryParam("currentProject") @NotNull String currentProjectPath, 
                @QueryParam("reference") @NotNull String buildReference, 
                @QueryParam("reportName") @NotNull String reportName, 
                @QueryParam("severityLevel") @NotNull CodeProblem.Severity severityLevel) {
        if (SecurityUtils.getUser() == null)
            throw new UnauthenticatedException();

        var currentProject = getProject(currentProjectPath);
        var build = getBuild(currentProject, buildReference);

        if (!SecurityUtils.canAccessReport(build, reportName))
            throw new UnauthorizedException("No permission to access report: " + reportName);

        var report = ProblemReport.readFrom(build, reportName);
        if (report == null)
            throw new NotFoundException("Code problem report not found: " + reportName);

        var problems = new ArrayList<Map<String, Object>>();
        for (var problem: report.getProblems()) {
            if (problem.getSeverity().ordinal() <= severityLevel.ordinal()) {
                var problemMap = new HashMap<String, Object>();
                problemMap.put("severity", problem.getSeverity().name());
                problemMap.put("message", problem.getMessage());
                if (problem.getTarget() instanceof BlobTarget blobTarget) {
                    problemMap.put("file", blobTarget.getGroupKey().getName());
                    if (blobTarget.getLocation() != null) {
                        problemMap.put("beginLine", blobTarget.getLocation().getFromRow() + 1);
                        problemMap.put("endLine", blobTarget.getLocation().getToRow() + 1);
                    }
                } else if (problem.getTarget() instanceof ContainerTarget containerTarget) {
                    problemMap.put("target", containerTarget.getGroupKey().getName());
                    problemMap.put("platform", ((ContainerTarget.GroupKey) containerTarget.getGroupKey()).getPlatform());
                } else if (problem.getTarget() instanceof GeneralTarget generalTarget) {
                    problemMap.put("target", generalTarget.getGroupKey().getName());

View on GitHub (pinned to d44925c47c)

Solutions

  1. Check the exact report name in the CI job's publishReport spec and use that name in the reportName param
  2. List available reports via GET /api/builds/{id}/reports to find valid names
  3. Re-run the build so the publish-report step produces the report
  4. Point the reference param at a build that actually published the code problem report

Example fix

// before
GET /~api/tod/get-build-code-problems?currentProject=app&reference=42&reportName=problem
// after
GET /~api/tod/get-build-code-problems?currentProject=app&reference=42&reportName=code-problems  # exact published report name
Defensive patterns

Strategy: validation

Validate before calling

const reports = await listBuildReports(buildId); if (!reports.some(r => r.name === reportName)) throw new Error(`No report '${reportName}' on build ${buildId}; available: ${reports.map(r=>r.name).join(',')}`);

Type guard

function hasReport(reports, name) { return Array.isArray(reports) && reports.some(r => r?.name === name); }

Try / catch

try { await getBuildCodeProblems(params); } catch (e) { if (e.status === 404 || /report not found/i.test(e.message)) { const avail = await listBuildReports(buildId); throw new Error('Unknown report; available: ' + avail.map(r=>r.name).join(',')); } throw e; }

Prevention

When it happens

Trigger: Calling get-build-code-problems with a reportName that was never published on the build (typo, different job published it, build has no problems report), or the report only exists on newer/other builds.

Common situations: Renamed report in CI job spec; build finished before the publish-report step ran; querying an old build from before the report was introduced; case mismatch in report name.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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