theonedev/onedev · error · NotFoundException

Not found

Error message

Not found

What it means

Thrown by the /edit-pull-request endpoint when syncing the 'labels' field fails because one of the supplied label names does not exist in the project. The underlying pullRequestLabelService.sync() throws EntityNotFoundException, which is re-wrapped as a NotFoundException with the original message (typically naming the missing label).

Source

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

        if (!SecurityUtils.canModifyPullRequest(request))
            throw new UnauthorizedException("No permission to edit pull request: " + pullRequestReference);

        normalizePullRequestData(data);

        var title = (String) data.remove("title");
        if (title != null) 
            pullRequestChangeService.changeTitle(user, request, title);

        if (data.containsKey("description")) 
            pullRequestChangeService.changeDescription(user, request, (String) data.remove("description"));

        var labelNames = (List<String>) data.remove("labels");
        if (labelNames != null) {
            try {
                pullRequestLabelService.sync(request, labelNames);
            } catch (EntityNotFoundException e) {
                throw new NotFoundException(e.getMessage());
            }
        }

        var mergeStrategyName = (String) data.remove("mergeStrategy");
        if (mergeStrategyName != null) {
            if (!request.isOpen())
                throw new NotAcceptableException("Pull request is closed");
            pullRequestChangeService.changeMergeStrategy(user, request, MergeStrategy.valueOf(mergeStrategyName));
        }

        var assigneeNames = (List<String>) data.remove("assignees");
        if (assigneeNames != null) {                        
            if (!request.isOpen())
                throw new NotAcceptableException("Pull request is closed");
            for (var assigneeName : assigneeNames) {
                User assignee = userService.findByName(assigneeName);
                if (assignee == null)
                    throw new NotFoundException("Assignee not found: " + assigneeName);

View on GitHub (pinned to d44925c47c)

Solutions

  1. Check the error message for the missing label name and create that label in the project (Project -> Pull Requests -> Labels) before retrying.
  2. Verify label spelling and exact case against the project's existing label list.
  3. Ensure you are passing labels that belong to the same project as currentProject, not another project's labels.
  4. Remove the unknown label from the 'labels' array or call the label-creation API first.

Example fix

// before
{"labels": ["bug", "priorty-high"]}
// after
{"labels": ["bug", "priority-high"]}  // corrected to an existing label name
Defensive patterns

Strategy: validation

Validate before calling

const projectLabels = await getProjectLabels(currentProject);
const invalid = labels.filter(l => !projectLabels.some(p => p.name === l));
if (invalid.length) throw new Error(`Labels not found in project: ${invalid.join(', ')}`);

Try / catch

try {
  await editPullRequest(ref, { labels });
} catch (e) {
  if (e.status === 404 && /label/i.test(e.message)) {
    // sync label list from project and retry with valid names
  }
}

Prevention

When it happens

Trigger: POST /edit-pull-request with a 'labels' array containing a label name that does not exist on the target project (or is referenced from a different project than the one holding the label definitions).

Common situations: Typos or case mismatches in label names; labels defined in another project than currentProject; labels deleted after an AI/automation script captured an old label list; tooling that copies labels across projects without creating them first.

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/aef40170d92a59ad. Report an issue: GitHub.