theonedev/onedev · error · NotAcceptableException
Invalid pack ID: {0}
Error message
Invalid pack ID: {0} What it means
PackDetailPage parses the pack ID from page parameters; a non-numeric ID throws NotAcceptableException with this message. It validates format only — a valid Long that doesn't correspond to a pack will instead fail later in PackService.load.
Source
Thrown at server-core/src/main/java/io/onedev/server/web/page/project/packs/detail/PackDetailPage.java:66
protected final IModel<Pack> packModel;
public PackDetailPage(PageParameters params) {
super(params);
String packIdString = params.get(PARAM_PACK).toString();
if (StringUtils.isBlank(packIdString))
throw new RestartResponseException(ProjectPacksPage.class, ProjectPacksPage.paramsOf(getProject(), null, 0));
packModel = new LoadableDetachableModel<>() {
@Override
protected Pack load() {
Long packId;
try {
packId = Long.valueOf(packIdString);
} catch (NumberFormatException e) {
throw new NotAcceptableException(MessageFormat.format(_T("Invalid pack ID: {0}"), packIdString));
}
return OneDev.getInstance(PackService.class).load(packId);
}
};
}
public Pack getPack() {
return packModel.getObject();
}
@Override
protected boolean isPermitted() {
return SecurityUtils.canReadPack(getProject());
}
@Override
protected BookmarkablePageLink<Void> navToProject(String componentId, Project project) {View on GitHub (pinned to d44925c47c)
Solutions
- Use the numeric pack ID in the pack detail URL.
- Obtain the ID from the pack object (pack.getId()) when generating links.
- Fix truncated or corrupted URL segments.
Example fix
// before String url = "/~packs/" + packName; // after String url = "/~packs/" + pack.getId();
Defensive patterns
Strategy: validation
Validate before calling
if (!packIdString.matches("\\d+")) throw new IllegalArgumentException("Pack ID must be numeric: " + packIdString);
Long packId = Long.valueOf(packIdString); Type guard
Long parsePackId(String s) { try { return Long.valueOf(s); } catch (NumberFormatException e) { return null; } } Try / catch
try { pack = packService.load(packId); } catch (NumberFormatException e) { log.error("Malformed pack id"); } Prevention
- Build pack URLs from pack.getId(), not names or hand-written strings.
- Keep numeric IDs intact when copying/sharing URLs.
- Avoid manual URL edits for pack pages.
When it happens
Trigger: Visiting a pack detail URL where the ID segment is not a number, e.g. /~packs/xyz; malformed or hand-edited URLs; code interpolating a package name instead of its numeric ID.
Common situations: Copying only part of a pack URL; scripts using a human-readable package name where the numeric pack ID is required; stale link templates after URL scheme changes.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Invalid issue number: {0}
- Invalid pull request number: {0}
- Invalid number: ${token}
- Resource class not found: ${className}
- Unexpected setting: {0}
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/21d14ef489057d5d.
Report an issue: GitHub.