theonedev/onedev · error · AttachmentTooLargeException
Upload must be less than
Error message
Upload must be less than
What it means
DefaultAttachmentService streams attachment uploads to storage and enforces maxUploadFileSize (the system's attachment size limit). If the streamed byte count exceeds the limit mid-upload, it throws AttachmentTooLargeException('Upload must be less than <human-readable size>').
Source
Thrown at server-core/src/main/java/io/onedev/server/attachment/DefaultAttachmentService.java:605
attachmentName = nameBeforeExt + "_" + index + "." + ext;
} else {
attachmentName = suggestedAttachmentNameCopy + "_" + index;
}
index++;
}
long maxUploadFileSize = settingService.getPerformanceSetting().getMaxUploadFileSize() * 1024L * 1024L;
Exception ex = null;
File file = new File(attachmentDir, attachmentName);
try (var os = new BufferedOutputStream(new FileOutputStream(file), BUFFER_SIZE)) {
byte[] buffer = new byte[BUFFER_SIZE];
long count = 0;
int n;
while (-1 != (n = attachmentStream.read(buffer))) {
count += n;
if (count > maxUploadFileSize) {
throw new AttachmentTooLargeException("Upload must be less than "
+ FileUtils.byteCountToDisplaySize(maxUploadFileSize));
}
os.write(buffer, 0, n);
}
} catch (Exception e) {
ex = e;
}
if (ex != null) {
if (file.exists())
FileUtils.deleteFile(file);
throw ExceptionUtils.unchecked(ex);
} else {
if (!attachmentDir.getParentFile().getName().equals(TEMP))
projectService.directoryModified(projectId, attachmentDir);
return file.getName();
}
});
}View on GitHub (pinned to d44925c47c)
Solutions
- Compress or split the file so it is under the configured limit.
- Have an administrator raise max file upload size in Administration -> System Setting.
- Upload large artifacts to external storage and attach a link instead.
Example fix
# before upload 'build-log-2GB.txt' # exceeds limit # after gzip -k build-log-2GB.txt # or raise limit in Administration -> System Setting upload 'build-log-2GB.txt.gz'
Defensive patterns
Strategy: validation
Validate before calling
const maxBytes = await getMaxUploadFileSize(); // from system setting
if (file.size >= maxBytes) throw new Error(`File exceeds limit of ${maxBytes} bytes; compress or raise the limit`); Try / catch
try { uploadAttachment(file); } catch (e) { if (/Upload must be less than/.test(e.message)) { const smaller = await compressOrSplit(file); return uploadAttachment(smaller); } throw e; } Prevention
- Check file size client-side against maxUploadFileSize before uploading
- Compress large logs/dumps before attaching
- Keep the system setting limit aligned with your team's artifact sizes
When it happens
Trigger: Uploading any attachment (issue comment file, build artifact attachment) whose size exceeds maxUploadFileSize configured in OneDev system settings.
Common situations: Users attaching large log files, dumps, or binaries; administrators lowering the limit without informing users; default limits too small for artifact-heavy workflows.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- Upload project not found:
- Invalid uploaded content: hash not equals to object id
- Unauthorized
- Parameter 'attachment-group' has to be specified
- Invalid parameter 'attachment-group'
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/451d02217e9a7d9e.
Report an issue: GitHub.