theonedev/onedev · error · UnauthorizedException

No package read permission for project: ${project.getPath()}

Error message

No package read permission for project: ${project.getPath()}

What it means

checkProject throws UnauthorizedException when a read operation (download/lookup) is requested and SecurityUtils.canReadPack(project) is false — the authenticated user cannot read packages in the project.

Source

Thrown at server-plugin/server-plugin-pack-helm/src/main/java/io/onedev/server/plugin/pack/helm/HelmPackHandler.java:261

            }));
        } else {
            throw new ClientException(SC_METHOD_NOT_ALLOWED, "Method not allowed");
        }
    }

    @Override
    public String getApiKey(HttpServletRequest request) {
        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;
	}

	private String getDownloadUrl(Pack pack) {
		return String.format("/%s/~helm/%s-%s.tgz",
				pack.getProject().getPath(), pack.getName(), pack.getVersion());
	}

	@Override
	public List<String> normalize(List<String> pathSegments) {
        pathSegments = new ArrayList<>(pathSegments);
        if (pathSegments.get(pathSegments.size() - 1).equals("charts")) {
            pathSegments.remove(pathSegments.size() - 1);
            if (pathSegments.get(0).equals("api")) 
                pathSegments.remove(0);
        }        
		return pathSegments;

View on GitHub (pinned to d44925c47c)

Solutions

  1. Configure the client with credentials of an account that can read the project's packages (e.g. helm repo add with username/password)
  2. Grant the user read-pack permission via project roles
  3. If the chart should be public, enable public/read access or move it to a project with public packages
  4. Check that the CI job token has read access to the target project

Example fix

// before (anonymous)
helm repo add onedev https://server/my-project/~helm
// after
helm repo add onedev https://server/my-project/~helm --username <user> --password <token>
Defensive patterns

Strategy: validation

Validate before calling

// configure client credentials and verify read access first
var resp = GET /api/projects/{path} with basic auth
if (resp.status == 401) throw new SecurityException("credentials lack pack read access");

Try / catch

try { pullChart(); } catch (UnauthorizedException e) { log.error("no pack read permission: {}", e.getMessage()); configureCredentials(); }

Prevention

When it happens

Trigger: GET/HEAD of a chart from /~helm by an anonymous or insufficiently-privileged user; helm/curl clients without credentials accessing a private project's packages.

Common situations: Pulling charts in CI without configuring credentials for a private registry, users removed from the project, or public reads attempted against a project with restricted pack read access.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


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