theonedev/onedev · error · ClientException

Package management not enabled for project ''

Error message

Package management not enabled for project ''

What it means

Thrown by checkProject before any npm registry operation when the target project does not have Package Management enabled. OneDev returns HTTP 406 (Not Acceptable) with the project path in the message, so npm clients see a 406 during publish, metadata fetch, or tarball download.

Source

Thrown at server-plugin/server-plugin-pack-npm/src/main/java/io/onedev/server/plugin/pack/npm/NpmPackHandler.java:581

					throw new ClientException(SC_BAD_REQUEST, "Invalid request path");
				}
			}
		}
	}

	@Override
	public String getApiKey(HttpServletRequest request) {
		var authzHeader = request.getHeader(HttpHeaders.AUTHORIZATION);
		if (authzHeader != null&& authzHeader.toLowerCase().startsWith("bearer ")) 
			return StringUtils.substringAfter(authzHeader, " ");
		else
			return null;
	}

	private Project checkProject(Long projectId, boolean needsToWrite) {
		var project = projectService.load(projectId);
		if (!project.isPackManagement())
			throw new ClientException(SC_NOT_ACCEPTABLE, "Package management not enabled for project '" + project.getPath() + "'");
		else if (needsToWrite && !SecurityUtils.canWritePack(project))
			throw new UnauthorizedException("No package write permission for project: " + project.getPath());
		else if (!needsToWrite && !SecurityUtils.canReadPack(project))
			throw new UnauthorizedException("No package read permission for project: " + project.getPath());
		return project;
	}
	
	@Override
	public List<String> normalize(List<String> pathSegments) {
		return pathSegments;
	}

}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Enable Package Management in the project: Project -> Packages (or Administration/Project settings) -> enable package management.
  2. Confirm the registry URL references the intended project path that has package management enabled.
  3. If the project was recently renamed/moved, update .npmrc to the new project path.

Example fix

// before (.npmrc) — project without packages
registry=https://onedev.example.com/npm/plain-project/
// after — enable packages on 'proj' first
registry=https://onedev.example.com/npm/proj/
Defensive patterns

Strategy: validation

Validate before calling

// Check via API that the project has package management before using npm registry
const resp = await fetch(`${onedevUrl}/~api/projects/${encodePath(projectPath)}`, { headers: auth });
const project = await resp.json();
if (!project.packManagement) throw new Error(`Enable package management on ${projectPath} first`);

Prevention

When it happens

Trigger: Any npm request (publish, metadata, tarball) whose projectId resolves to a project where project.isPackManagement() is false — checkProject runs inside every routed operation.

Common situations: Pointing .npmrc at a OneDev project created before enabling packages; moving the registry to a different project that lacks the feature; project settings reset or feature disabled by an admin.

Related errors


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