microsoft/aspire · error · InvalidOperationException
File input ' ' accepts at most .
Error message
File input '{inputName}' accepts at most {maxFileCount} {fileLabel}. What it means
Each file input declares a maximum file count (maxFileCount). The store counts existing and in-progress upload entries for that input and, since uploads count toward the limit even while in flight, any upload beyond the cap is rejected. The message uses singular/plural 'file/files' based on the limit.
Solutions
- Limit client-side file selection to the input's maxFileCount before submitting
- Remove completed/unwanted entries for the input before uploading new files if the flow allows re-selection
- Catch InvalidOperationException and inform the user of the maximum ('at most N files')
- Serialize uploads per input and check the count immediately before each CreateEntry call
Example fix
// before
foreach (var file in selectedFiles) // may exceed limit mid-loop
await store.CreateEntry(interactionId, inputName, file.Name, file.Stream);
// after
foreach (var file in selectedFiles.Take(maxFileCount))
await store.CreateEntry(interactionId, inputName, file.Name, file.Stream); Defensive patterns
Strategy: validation
Validate before calling
var current = interaction.Files.Values.Count(f => string.Equals(f.InputName, inputName, StringComparisons.InteractionInputName));
if (current >= interaction.FileInputLimits[inputName])
{
throw new InvalidOperationException($"Input '{inputName}' already at its file limit.");
} Type guard
bool UnderLimit(InteractionFileUploadStore.Interaction i, string inputName) =>
i.FileInputLimits.TryGetValue(inputName, out var max) &&
i.Files.Values.Count(f => f.InputName == inputName) < max; Try / catch
try
{
await store.CreateEntry(interactionId, inputName, fileName, stream);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("accepts at most"))
{
// Enforce the limit in the UI and inform the user.
} Prevention
- Clamp client-side selections to maxFileCount before upload
- Serialize uploads per input to avoid racing the count
- Remove superseded entries before re-uploading a selection
- Show the per-input limit in the upload UI
When it happens
Trigger: Calling CreateEntry for an input whose current fileCount already equals maxFileCount — e.g. uploading a third file to an input configured for two, or concurrent uploads racing to exceed the limit.
Common situations: Client-side UI allowing more files than the input's declared maximum; user selecting a multi-file set larger than the cap; double-submission of the same selection adding duplicate entries.
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
- File ' ' exceeded the expected size of bytes.
- Interaction ' ' is not accepting file uploads for input ' '.
- Submitted files for input
- AppHost:ResourceService:ApiKey is not specified in…
- [aspire-terminal] WS closed abnormally
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/8ca74099298d4014.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/Dashboard/InteractionFileUploadStore.cs:69
{
if (interaction.State != FileInteractionState.InProgress)
{
throw new InvalidOperationException($"Interaction '{interactionId}' is not accepting file uploads.");
}
if (!interaction.FileInputLimits.TryGetValue(inputName, out var maxFileCount))
{
throw new InvalidOperationException($"Interaction '{interactionId}' is not accepting file uploads for input '{inputName}'.");
}
// Each client submits one file selection per input during an interaction. Multi-file selections upload
// their files sequentially as part of that single selection, so every upload counts toward this limit.
// Count uploads in progress as reserved slots so concurrent requests cannot exceed the input's limit.
var fileCount = interaction.Files.Values.Count(entry => string.Equals(entry.InputName, inputName, StringComparisons.InteractionInputName));
if (fileCount >= maxFileCount)
{
var fileLabel = maxFileCount == 1 ? "file" : "files";
throw new InvalidOperationException($"File input '{inputName}' accepts at most {maxFileCount} {fileLabel}.");
}
// Keep only the leaf name as metadata. The client-supplied name is never used for the
// on-disk path because filename rules vary by platform and some names have special semantics.
var lastSep = originalFileName.AsSpan().LastIndexOfAny('/', '\\');
var safeName = lastSep >= 0 ? originalFileName[(lastSep + 1)..] : originalFileName;
var tempFile = _tempFileSystem.CreateTempFile();
var fileId = Guid.NewGuid().ToString("N");
interaction.Files[fileId] = new FileEntry(tempFile, inputName, safeName);
_logger.LogDebug(
"Created uploaded file entry {FileId} for interaction {InteractionId}, input {InputName}, and file {FileName}.",
fileId,
interactionId,
inputName,
safeName);
return (fileId, tempFile.Path);View on GitHub (pinned to 25830f84bd)