fullstackhero/dotnet-starter-kit · error · CustomException
Storage quota exceeded
Error message
Storage quota exceeded ({check.CurrentUsage}/{check.Limit} bytes). What it means
QuotaMeteredStorageService.UploadAsync checks the tenant's current storage usage against its configured limit before writing a blob. When the post-upload usage would exceed the limit, it throws CustomException with HTTP 507 (InsufficientStorage). This is an intentional quota guard, not a bug — the tenant has filled its allocated storage.
Solutions
- Increase the tenant's storage limit (quota configuration) if the allocation is too small.
- Free space by deleting unused files for that tenant, then retry the upload.
- Handle the 507 status client-side and surface a 'storage full' message prompting cleanup or an upgrade.
- Enable size pre-checks client-side: reject files before upload when remaining quota is insufficient.
Example fix
// before: blind upload
collection.Add(file);
await storage.UploadAsync(request);
// after: pre-check quota client-side
var check = await quotaClient.CheckAsync(tenantId);
if (check.CurrentUsage + file.Length > check.Limit)
return Results.StatusCode(507); // or trim / upgrade quota Defensive patterns
Strategy: try-catch
Validate before calling
var check = await quotaService.GetCurrentUsageAsync(tenantId);
if (check.CurrentUsage + file.Length >= check.Limit)
throw new InvalidOperationException("Upload would exceed tenant storage quota."); Type guard
bool HasQuotaRoom(QuotaCheck c, long incomingBytes) => c.CurrentUsage + incomingBytes < c.Limit;
Try / catch
try {
await storage.UploadAsync(request);
} catch (CustomException ex) when ((int)ex.StatusCode == 507) {
// inform user storage is full; offer cleanup or quota increase
} Prevention
- Show remaining quota in the UI and block uploads that would exceed it.
- Alert tenants at 80–90% usage.
- Periodically clean orphaned blobs and recompute usage.
When it happens
Trigger: Calling UploadAsync when check.CurrentUsage + request payload size exceeds the tenant's configured byte limit. Common with the default quota on new tenants, or after bulk uploads.
Common situations: Production tenants uploading large media; staging tenants importing demo datasets that exceed default limits; quota limit configured too low in tenant settings; files never deleted so usage ratchets up over time.
Related errors
- Storage quota exceeded
- File type ' ' is not allowed. Allowed
- File exceeds max size of
- File type ' ' is not allowed. Allowed
- File exceeds max size of
AI-assisted analysis of fullstackhero/dotnet-starter-kit@3f2959e683 (2026-09-15).
Data as JSON: /api/errors/89bc3287b9039175.
Report an issue: GitHub.
Appendix: source
Thrown at src/BuildingBlocks/Storage/QuotaMeteredStorageService.cs:69
{
return await _inner.UploadAsync<T>(request, fileType, cancellationToken).ConfigureAwait(false);
}
var bytes = request.Data.Count;
var check = await _quotas
.CheckAndRecordAsync(tenantId, QuotaResource.StorageBytes, bytes, cancellationToken)
.ConfigureAwait(false);
if (!check.Allowed)
{
if (_logger.IsEnabled(LogLevel.Warning))
{
_logger.LogWarning(
"Rejected upload for tenant {TenantId} — storage quota exceeded ({Current}/{Limit} bytes)",
tenantId, check.CurrentUsage, check.Limit);
}
throw new CustomException(
$"Storage quota exceeded ({check.CurrentUsage}/{check.Limit} bytes).",
errors: null,
HttpStatusCode.InsufficientStorage);
}
try
{
return await _inner.UploadAsync<T>(request, fileType, cancellationToken).ConfigureAwait(false);
}
catch
{
// Roll the charge back so a failed write doesn't permanently consume quota.
await _quotas
.RecordAsync(tenantId, QuotaResource.StorageBytes, -bytes, CancellationToken.None)
.ConfigureAwait(false);
throw;
}
}View on GitHub (pinned to 3f2959e683)