theonedev/onedev · warning · NotAcceptableException
Invalid content disposition: ${disposition}
Error message
Invalid content disposition: ${disposition} What it means
RawBlobResource accepts an optional disposition URL parameter that must be one of the ContentDisposition enum values (e.g. attachment, inline). Passing any other string makes ContentDisposition.valueOf throw IllegalArgumentException, which the resource converts into NotAcceptableException.
Source
Thrown at server-core/src/main/java/io/onedev/server/web/resource/RawBlobResource.java:112
response.setContentLength(blob.getLfsPointer().getObjectSize());
else
response.setContentLength(blob.getSize());
if (!ObjectId.isId(revision))
response.disableCaching();
try {
response.setFileName(URLEncoder.encode(blob.getIdent().getName(), StandardCharsets.UTF_8.name()));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
String disposition = params.get(PARAM_DISPOSITION).toOptionalString();
if (disposition != null) {
try {
response.setContentDisposition(ContentDisposition.valueOf(disposition));
} catch (IllegalArgumentException e) {
throw new NotAcceptableException("Invalid content disposition: " + disposition);
}
}
response.setWriteCallback(new WriteCallback() {
@Override
public void writeData(Attributes attributes) throws IOException {
try (InputStream is = getInputStream(blob)) {
long contentLength;
if (blob.getLfsPointer() != null)
contentLength = blob.getLfsPointer().getObjectSize() - 1;
else
contentLength = blob.getSize() - 1;
LongRange range = WicketUtils.getRequestContentRange(contentLength);
try {
IOUtils.copyRange(is, attributes.getResponse().getOutputStream(), range);
} catch (Exception e) {View on GitHub (pinned to d44925c47c)
Solutions
- Use an exact valid ContentDisposition value (e.g. attachment or inline) in the disposition parameter.
- Check casing — the value is matched against enum constants exactly.
- Remove the disposition parameter if you don't need to control content disposition.
Example fix
// before String url = "/~raw/proj/main/a.zip?disposition=Attachment"; // after String url = "/~raw/proj/main/a.zip?disposition=attachment";
Defensive patterns
Strategy: validation
Validate before calling
Set.of("attachment","inline").contains(disposition) /* or check ContentDisposition enum */ Type guard
boolean isValidDisposition(String d) { return d == null || Arrays.stream(ContentDisposition.values()).anyMatch(c -> c.name().equalsIgnoreCase(d)); } Try / catch
try { /* request */ } catch (NotAcceptableException e) { /* fix disposition param */ } Prevention
- Only pass lowercase enum-constant values for the disposition parameter.
- Omit the parameter unless you specifically need attachment/inline behavior.
When it happens
Trigger: Raw blob request with ?disposition=<invalid value> where the value is not a valid ContentDisposition enum constant (case-sensitive).
Common situations: Typos like 'attachement' or 'inline;' in generated download links; passing a filename instead of a disposition keyword; case mismatch ('Attachment' vs 'attachment').
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unauthenticated
- Project not specified
- Project not found or inaccessible: <projectPath>
- Authentication required
- Project not specified
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/5fb315ffd480a543.
Report an issue: GitHub.