theonedev/onedev · error · NotAcceptableException

Project not found: ${projectPath}

Error message

Project not found: ${projectPath}

What it means

The job trigger endpoint (/~api/trigger-job?project=...) resolves the project via projectService.findByPath(projectPath). If no project matches the given path, NotAcceptableException (406) with 'Project not found: <path>' is thrown. The project path is the URL-ish path of the project (e.g. 'myorg/myrepo' or '~user/project').

Source

Thrown at server-core/src/main/java/io/onedev/server/rest/resource/TriggerJobResource.java:102

    }
	
	@Api(order=100, description=DESCRIPTION)
	@POST
    public Long triggerJobViaPost(
    		@Api(description="Path of the project") @QueryParam(PARAM_PROJECT) @NotEmpty String projectPath, 
    		@Api(description=REF_DESCRIPTION) @QueryParam(PARAM_BRANCH) @Nullable String branch, 
    		@Api(description=REF_DESCRIPTION) @QueryParam(PARAM_TAG) @Nullable String tag, 
    		@QueryParam(PARAM_JOB) @NotEmpty String job,
			@Api(description=ACCESS_TOKEN_DESCRIPTION) @QueryParam(PARAM_ACCESS_TOKEN) @NotEmpty String accessToken, 
    		@Context UriInfo uriInfo) {
		return triggerJob(projectPath, branch, tag, job, accessToken, uriInfo);
    }

    private Long triggerJob(String projectPath, @Nullable String branch, @Nullable String tag, String job,
							String accessTokenValue, UriInfo uriInfo) {
		Project project = projectService.findByPath(projectPath);
		if (project == null)
			throw new NotAcceptableException("Project not found: " + projectPath);

		var accessToken = accessTokenService.findByValue(accessTokenValue);
		if (accessToken == null)
			throw new NotAcceptableException("Invalid access token");
		
		var subject = accessToken.asSubject();
		var user = SecurityUtils.getUser(subject);
		ThreadContext.bind(subject);
		try {
			if (!SecurityUtils.canRunJob(subject, project, job))		
				throw new UnauthorizedException();

			if (StringUtils.isNotBlank(branch) && StringUtils.isNotBlank(tag)) 
				throw new NotAcceptableException("Either branch or tag should be specified, but not both");
			
			String refName;
			if (branch != null)
				refName = GitUtils.branch2ref(branch);

View on GitHub (pinned to d44925c47c)

Solutions

  1. Check the project path in OneDev UI and pass the exact path in the 'project' parameter.
  2. Include the parent hierarchy in the path (e.g. 'group/sub/project'), not just the last segment.
  3. Confirm the project is not renamed/deleted and update the calling script accordingly.

Example fix

// before
curl 'http://onedev/~api/trigger-job?project=myrepo&job=CI&access_token=...'
// after (use full path, URL-encoded)
curl 'http://onedev/~api/trigger-job?project=myorg%2Fmyrepo&job=CI&access_token=...'
Defensive patterns

Strategy: validation

Validate before calling

const project = await fetch(`/~api/projects?path=${encodeURIComponent(projectPath)}`, {headers: {Authorization: auth}}).then(r => r.json());
if (!project) throw new Error(`Project not found: ${projectPath}`);

Prevention

When it happens

Trigger: GET/POST trigger-job with 'project' query parameter not matching any existing project path, including typos, wrong case, missing parent path, or a path of a deleted/archived project.

Common situations: Renaming or moving a project without updating CI scripts; using repo slug instead of full path; trailing/leading whitespace or wrong URL encoding; project deleted before the trigger ran.

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