immich-app/immich · error · BadRequestException
Quota has been exceeded!
Error message
Quota has been exceeded!
What it means
Thrown by AssetMediaService.requireQuota as BadRequestException (HTTP 400) when the authenticated user's quota would be exceeded by the upload: auth.user.quotaSizeInBytes is non-null and quotaUsageInBytes + file.size exceeds it. The check runs after the upload-access check but during uploadAsset, before the asset is committed.
Source
Thrown at server/src/services/asset-media.service.ts:370
}
const album = await this.albumRepository.getById(sharedLink.albumId, { withAssets: false });
if (!album) {
return;
}
await this.albumRepository.addAssetIds(album.id, [assetId]);
const userIds = album.albumUsers.map(({ user }) => user.id);
await this.eventRepository.emit('AlbumUpdate', {
id: album.id,
userIds,
recipientIds: userIds,
});
}
private requireQuota(auth: AuthDto, size: number) {
if (auth.user.quotaSizeInBytes !== null && auth.user.quotaSizeInBytes < auth.user.quotaUsageInBytes + size) {
throw new BadRequestException('Quota has been exceeded!');
}
}
}
View on GitHub (pinned to 199723261c)
Solutions
- Free up space by deleting existing assets to get below quota
- Ask an admin to raise the user's quotaSizeInBytes (User management → quota)
- Check current usage vs quota before starting a bulk upload and skip/throttle accordingly
- Upload smaller files or compress media first
Example fix
// before for (const f of files) await sdk.uploadAsset(f); // 400 on the one that tips over // after const me = await sdk.getMyUser(); const remaining = me.quotaSizeInBytes - me.quotaUsageInBytes; const fitting = files.filter(f => f.size <= remaining);
Defensive patterns
Strategy: validation
Validate before calling
// Check remaining quota before uploading
const me = await sdk.getMyUser();
if (me.quotaSizeInBytes != null) {
const remaining = me.quotaSizeInBytes - me.quotaUsageInBytes;
if (file.size > remaining) {
throw new Error(`Upload would exceed quota (need ${file.size}, have ${remaining})`);
}
}
await sdk.uploadAsset(file); Type guard
function hasQuota(u: { quotaSizeInBytes?: number | null }): u is { quotaSizeInBytes: number; quotaUsageInBytes: number } {
return typeof u.quotaSizeInBytes === 'number';
} Prevention
- Fetch the user's quota and usage before starting a bulk upload; skip files that won't fit
- Have admins raise the quota or delete unused assets when approaching the limit
- Show remaining quota in the UI so users self-govern before upload
When it happens
Trigger: POST /assets (upload) where the incoming file size pushes the user's total stored bytes above their configured quotaSizeInBytes. Only fires when an admin has set a non-null quota for the user.
Common situations: User on a capped plan; admin sets quota after the user already approached the limit; bulk upload of large media that crosses the threshold mid-batch.
Related errors
- Unsupported file type ${filename}
- May not request original file
- Asset not found or asset is not a video
- Both assets must exist
- Source and target id must be distinct
AI-assisted analysis of immich-app/immich@199723261c (2026-08-12).
Data as JSON: /api/errors/f746026fbda586bf.
Report an issue: GitHub.