theonedev/onedev · error · UnauthorizedException
No package read permission for project: ${projectPath}
Error message
No package read permission for project: ${projectPath} What it means
Thrown by CargoPackHandler.checkProject when a read operation (download crate, fetch index) is requested but SecurityUtils.canReadPack(project) is false for the current user. An authorization failure raised before any package content is served.
Source
Thrown at server-plugin/server-plugin-pack-cargo/src/main/java/io/onedev/server/plugin/pack/cargo/CargoPackHandler.java:390
try {
objectMapper.writeValue(response.getOutputStream(), object);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private String getLockName(Long projectId, String name) {
return "update-pack:" + projectId + ":" + TYPE + ":" + name;
}
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 String getApiKey(HttpServletRequest request) {
return request.getHeader(HttpHeaders.AUTHORIZATION);
}
@Override
public List<String> normalize(List<String> pathSegments) {
return pathSegments;
}
private static class PublishBody {
private final byte[] metadata;
View on GitHub (pinned to d44925c47c)
Solutions
- Grant the user/team package read permission on the project
- Configure credentials in ~/.cargo/credentials or the registry section of .cargo/config.toml
- Ensure the CI token has read scope for packages
- Verify the index URL points at the project you are authorized for
Defensive patterns
Strategy: validation
Validate before calling
// ensure authenticated user can read packs on the target project // check membership/role in OneDev UI or via API before cargo fetch
Try / catch
try { execSync('cargo fetch'); } catch (e) { if (/No package read permission/.test(e.message)) { /* fix credentials or request access */ } } Prevention
- Configure registry credentials in .cargo/config.toml / credentials file
- Grant CI tokens read package scope
- Confirm anonymous access policy for the project
- Verify the project path in index URL
When it happens
Trigger: Running `cargo fetch`/build against the registry while logged in as a user lacking package read permission on the project, or anonymously on a private project.
Common situations: CI jobs using a token without read access; developer not added to the project; anonymous pulls against a project that requires login; wrong project path in the index URL giving access to a project the user can't read.
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
- No package write permission for project: ${projectPath}
- Access denied
- Issue schedule permission required to set own estimated time
- Issue schedule permission required to set iterations
- No permission to access issue: ${referenceString}
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/b5db35287b285959.
Report an issue: GitHub.