{"record":{"id":"20be0c5f6d051ad8","repo":"microsoft/aspire","slug":"prompt-id-interactionid-is-not-a-valid-interaction-id","errorCode":null,"errorMessage":"Prompt ID '{interactionId}' is not a valid interaction ID.","messagePattern":"Prompt ID '(.+?)' is not a valid interaction ID\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Commands/PipelineCommandBase.cs","lineNumber":1328,"sourceCode":"            cancellationToken: cancellationToken);\n\n        if (string.IsNullOrWhiteSpace(singleValue))\n        {\n            return string.Empty;\n        }\n\n        return await UploadFilesAsync([Path.GetFullPath(singleValue)], backchannel, interactionId, inputName, cancellationToken);\n    }\n\n    private static async Task<string> UploadFilesAsync(List<string> filePaths, IAppHostCliBackchannel backchannel, string interactionId, string inputName, CancellationToken cancellationToken)\n    {\n        if (filePaths.Count == 0)\n        {\n            return string.Empty;\n        }\n        if (!int.TryParse(interactionId, CultureInfo.InvariantCulture, out var interactionIdValue))\n        {\n            throw new InvalidOperationException($\"Prompt ID '{interactionId}' is not a valid interaction ID.\");\n        }\n\n        var fileRefs = new List<FileReferenceDto>(filePaths.Count);\n\n        foreach (var filePath in filePaths)\n        {\n            var fullPath = Path.GetFullPath(filePath);\n            var fileName = Path.GetFileName(fullPath);\n\n            // Upload the file to the AppHost and collect the reference.\n            // Matching the same format the dashboard uses: [{\"Id\":\"...\",\"Name\":\"...\"}]\n            var uploadResponse = await backchannel.UploadFileAsync(fullPath, fileName, interactionIdValue, inputName, cancellationToken);\n            fileRefs.Add(new FileReferenceDto { Id = uploadResponse.FileId, Name = fileName });\n        }\n\n        return JsonSerializer.Serialize(fileRefs.ToArray(), BackchannelJsonSerializerContext.Default.FileReferenceDtoArray);\n    }\n","sourceCodeStart":1310,"sourceCodeEnd":1346,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Commands/PipelineCommandBase.cs#L1310-L1346","documentation":"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.","triggerScenarios":"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.","commonSituations":"Custom automation driving the prompt API with a fabricated interaction id; internal state corruption between prompt creation and completion; tests passing placeholder ids.","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"],"exampleFix":"// before\nawait CompleteFilePromptAsync(\"abc\", files);\n// after\nawait CompleteFilePromptAsync(interaction.Id.ToString(CultureInfo.InvariantCulture), files);","handlingStrategy":"validation","validationCode":"if (!int.TryParse(interactionId, CultureInfo.InvariantCulture, out _))\n    throw new ArgumentException($\"'{interactionId}' is not a valid interaction id.\");","typeGuard":null,"tryCatchPattern":"try { await CompleteFilePromptAsync(interactionId, files); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"valid interaction ID\")) { log.LogError(\"Corrupt interaction id: {Id}\", interactionId); }","preventionTips":["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"],"tags":["cli","prompt","file-input"],"backgroundTag":"invalid-argument-format","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"}