microsoft/aspire · error · InvalidOperationException

Interaction ' ' is not accepting file uploads for input ' '.

Error message

Interaction '{interactionId}' is not accepting file uploads for input '{inputName}'.

What it means

The store keeps a per-input limit table (FileInputLimits) describing which file inputs an interaction accepts. If the supplied inputName is not registered for the interaction, uploads for that input are rejected. This distinguishes 'interaction closed' from 'input not recognized'.

Solutions

  1. Verify the inputName exactly matches the name declared when the interaction's file input was added
  2. Re-fetch the interaction definition so the client uses the current input names
  3. Catch InvalidOperationException and report which inputs are accepted (from FileInputLimits) to aid debugging

Example fix

// before
await store.CreateEntry(interactionId, "attachment", file.Name, stream);
// after
var inputName = FileUploadInputs.Attachment; // must match the name registered in FileInputLimits
await store.CreateEntry(interactionId, inputName, file.Name, stream);
Defensive patterns

Strategy: validation

Validate before calling

if (!interaction.FileInputLimits.ContainsKey(inputName))
{
    throw new ArgumentException($"Input '{inputName}' is not registered for interaction '{interactionId}'.");
}

Type guard

bool IsKnownInput(InteractionFileUploadStore.Interaction i, string inputName) =>
    i.FileInputLimits.ContainsKey(inputName);

Try / catch

try
{
    await store.CreateEntry(interactionId, inputName, fileName, stream);
}
catch (InvalidOperationException ex) when (ex.Message.Contains($"for input '{inputName}'"))
{
    // Report the mismatch; list accepted inputs from interaction.FileInputLimits.
}

Prevention

When it happens

Trigger: CreateEntry called with an inputName that does not match any key in the interaction's FileInputLimits dictionary (typo'd name, input removed before upload, or upload sent for an input belonging to a different interaction).

Common situations: Frontend sending a form field name that changed after the interaction was created; client code uploading files for inputs declared with different casing or names; uploading to a completed interaction that had a differently-named input.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/addf393e113e2540. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting/Dashboard/InteractionFileUploadStore.cs:59

    /// Creates a new temp file path and returns the file ID and path.
    /// </summary>
    public (string FileId, string FilePath) CreateEntry(string originalFileName, int interactionId, string inputName)
    {
        if (!_interactions.TryGetValue(interactionId, out var interaction))
        {
            throw new InvalidOperationException($"Interaction '{interactionId}' is not accepting file uploads.");
        }

        lock (interaction)
        {
            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();

View on GitHub (pinned to 25830f84bd)