{"record":{"id":"6fe8e6fe5df8f56a","repo":"microsoft/aspire","slug":"resourceexhausted","errorCode":"ResourceExhausted","errorMessage":"Upload exceeds maximum allowed size of {maxTotalUploadBytes} bytes.","messagePattern":"Upload exceeds maximum allowed size of (.+?) bytes\\.","errorType":"http","errorClass":"RpcException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Dashboard/DashboardService.cs","lineNumber":550,"sourceCode":"                    string path;\n                    interactionId = chunk.InteractionId;\n                    try\n                    {\n                        (fileId, path) = fileUploadStore.CreateEntry(chunk.FileName, interactionId.Value, chunk.InputName);\n                    }\n                    catch (InvalidOperationException ex)\n                    {\n                        throw new RpcException(new Status(StatusCode.FailedPrecondition, ex.Message));\n                    }\n                    fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize: 81920, useAsync: true);\n                }\n\n                if (!chunk.Data.IsEmpty)\n                {\n                    totalBytesWritten += chunk.Data.Length;\n                    if (totalBytesWritten > maxTotalUploadBytes)\n                    {\n                        throw new RpcException(new Status(StatusCode.ResourceExhausted, $\"Upload exceeds maximum allowed size of {maxTotalUploadBytes} bytes.\"));\n                    }\n\n                    await fileStream.WriteAsync(chunk.Data.Memory, cancellationToken).ConfigureAwait(false);\n                }\n            }\n\n            if (fileStream is null)\n            {\n                throw new RpcException(new Status(StatusCode.InvalidArgument, \"Upload stream is empty.\"));\n            }\n\n            // Close and flush the file before marking the upload complete. If disposal fails,\n            // the catch path removes the entry so a partial upload is never retained.\n            await fileStream.DisposeAsync().ConfigureAwait(false);\n            fileStream = null;\n\n            fileUploadStore.CompleteUpload(interactionId!.Value, fileId!);\n","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Dashboard/DashboardService.cs#L532-L568","documentation":"UploadFile enforces a total upload size cap of maxTotalUploadBytes. As chunks accumulate, once totalBytesWritten exceeds the cap an RpcException with StatusCode.ResourceExhausted is thrown and the upload is rejected, protecting the AppHost from unbounded temp-file growth.","triggerScenarios":"Streaming an upload whose cumulative Data bytes across all chunks exceed the configured maximum (e.g. a very large log or data file uploaded through a dashboard file input).","commonSituations":"Users selecting oversized files in a dashboard file input; automated clients streaming large blobs; a misconfigured or default upload limit smaller than expected.","solutions":["Upload a smaller file or compress/truncate the data before uploading.","Raise the maximum by adjusting the upload size limit configuration for the AppHost/resource service if your scenario legitimately needs larger files.","Chunk and send only the needed portion (e.g. last N bytes of a log) instead of the whole file.","Handle the ResourceExhausted status in the client and surface a friendly size-limit message to users."],"exampleFix":"// before\nawait foreach (var b in ReadWholeFile(path)) stream.RequestStream.WriteAsync(new UploadFileChunk { Data = b });\n// after\nconst long maxUpload = 10 * 1024 * 1024;\nif (new FileInfo(path).Length > maxUpload)\n{\n    throw new InvalidOperationException($\"File exceeds the {maxUpload} byte upload limit; compress or trim it first.\");\n}","handlingStrategy":"try-catch","validationCode":"var length = new FileInfo(path).Length;\nconst long maxUploadBytes = 10 * 1024 * 1024; // match the service's configured limit\nif (length > maxUploadBytes) throw new InvalidOperationException($\"File of {length} bytes exceeds the {maxUploadBytes} byte upload limit.\");","typeGuard":null,"tryCatchPattern":"try { await uploadTask; } catch (RpcException ex) when (ex.StatusCode == StatusCode.ResourceExhausted) { logger.LogWarning(\"Upload rejected: {Detail}\", ex.Status.Detail); /* surface size-limit message to user */ }","preventionTips":["Check file size before uploading","Compress or trim large files","Track cumulative bytes client-side during streaming","Configure the limit appropriately for your workload"],"tags":["grpc","upload","size-limit","dashboard"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}