microsoft/aspire · error · InvalidOperationException
Prompt ID ' ' is not a valid interaction ID.
Error message
Prompt ID '{interactionId}' is not a valid interaction ID. What it means
After the user picks files in the interactive file prompt, the CLI must send the selection back to the AppHost using the numeric interaction ID from the interaction service. If the stored interactionId string fails int parsing (it should always be an integer assigned by the interaction service), this InvalidOperationException is thrown before building FileReference payloads.
Solutions
- Use the interaction ID exactly as returned by the interaction service when completing the prompt
- Re-run the publish command; if reproducible, report an internal-state bug with reproduction steps
- Verify any test/automation code passes a valid numeric interaction id
Example fix
// before
await CompleteFilePromptAsync("abc", files);
// after
await CompleteFilePromptAsync(interaction.Id.ToString(CultureInfo.InvariantCulture), files); Defensive patterns
Strategy: validation
Validate before calling
if (!int.TryParse(interactionId, CultureInfo.InvariantCulture, out _))
throw new ArgumentException($"'{interactionId}' is not a valid interaction id."); Try / catch
try { await CompleteFilePromptAsync(interactionId, files); }
catch (InvalidOperationException ex) when (ex.Message.Contains("valid interaction ID")) { log.LogError("Corrupt interaction id: {Id}", interactionId); } Prevention
- Always round-trip the interaction id exactly as issued by the interaction service
- Never fabricate interaction ids in tests or automation
- Log the id at prompt creation to trace corruption
When it happens
Trigger: Completing a file-selection prompt where interactionId is null, empty, or non-numeric — e.g. a corrupted interaction record passed into the completion helper in HandleFileInputAsync's flow.
Common situations: Custom automation driving the prompt API with a fabricated interaction id; internal state corruption between prompt creation and completion; tests passing placeholder ids.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- File prompt input is missing a name.
- No items available for selection
- Prompt provided without input data.
- The option must be specified when running in…
- This prompt requires interactive input but the CLI is…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/20be0c5f6d051ad8.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Cli/Commands/PipelineCommandBase.cs:1328
cancellationToken: cancellationToken);
if (string.IsNullOrWhiteSpace(singleValue))
{
return string.Empty;
}
return await UploadFilesAsync([Path.GetFullPath(singleValue)], backchannel, interactionId, inputName, cancellationToken);
}
private static async Task<string> UploadFilesAsync(List<string> filePaths, IAppHostCliBackchannel backchannel, string interactionId, string inputName, CancellationToken cancellationToken)
{
if (filePaths.Count == 0)
{
return string.Empty;
}
if (!int.TryParse(interactionId, CultureInfo.InvariantCulture, out var interactionIdValue))
{
throw new InvalidOperationException($"Prompt ID '{interactionId}' is not a valid interaction ID.");
}
var fileRefs = new List<FileReferenceDto>(filePaths.Count);
foreach (var filePath in filePaths)
{
var fullPath = Path.GetFullPath(filePath);
var fileName = Path.GetFileName(fullPath);
// Upload the file to the AppHost and collect the reference.
// Matching the same format the dashboard uses: [{"Id":"...","Name":"..."}]
var uploadResponse = await backchannel.UploadFileAsync(fullPath, fileName, interactionIdValue, inputName, cancellationToken);
fileRefs.Add(new FileReferenceDto { Id = uploadResponse.FileId, Name = fileName });
}
return JsonSerializer.Serialize(fileRefs.ToArray(), BackchannelJsonSerializerContext.Default.FileReferenceDtoArray);
}
View on GitHub (pinned to 25830f84bd)