{"record":{"id":"5a604477fcf0db91","repo":"microsoft/aspire","slug":"unsupported-completion-state","errorCode":null,"errorMessage":"Unsupported completion state.","messagePattern":"Unsupported completion state\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Ats/PipelineExports.cs","lineNumber":202,"sourceCode":"    public static Task CompleteTaskMarkdown(this IReportingTask reportingTask, string markdownString, string completionState = \"completed\", CancellationToken cancellationToken = default)\n    {\n        ArgumentNullException.ThrowIfNull(reportingTask);\n        ArgumentNullException.ThrowIfNull(markdownString);\n\n        return reportingTask.CompleteAsync(new MarkdownString(markdownString), ParseCompletionState(completionState), cancellationToken);\n    }\n\n    private static CompletionState ParseCompletionState(string completionState)\n    {\n        ArgumentNullException.ThrowIfNull(completionState);\n\n        return completionState.ToLowerInvariant() switch\n        {\n            \"inprogress\" or \"in_progress\" or \"in-progress\" => CompletionState.InProgress,\n            \"completed\" => CompletionState.Completed,\n            \"completedwithwarning\" or \"completed_with_warning\" or \"completed-with-warning\" => CompletionState.CompletedWithWarning,\n            \"completedwitherror\" or \"completed_with_error\" or \"completed-with-error\" => CompletionState.CompletedWithError,\n            _ => throw new ArgumentOutOfRangeException(nameof(completionState), completionState, \"Unsupported completion state.\")\n        };\n    }\n\n    private static LogLevel ParseLogLevel(string level)\n    {\n        return LoggingExports.ParseLogLevel(level, throwOnUnknown: true);\n    }\n}\n","sourceCodeStart":184,"sourceCodeEnd":211,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Ats/PipelineExports.cs#L184-L211","documentation":"PipelineExports.ParseCompletionState maps a completion-state string to CompletionState and throws ArgumentOutOfRangeException for any string outside the accepted set: inprogress/in_progress/in-progress, completed, completedwithwarning/* variants, and completedwitherror/* variants. It is shared by CompleteStep, CompleteStepMarkdown, CompleteTask, and CompleteTaskMarkdown.","triggerScenarios":"Calling CompleteStep/CompleteStepMarkdown/CompleteTask/CompleteTaskMarkdown with a state string such as \"done\", \"failed\", \"success\", \"InProgress \", or an unsupported variant.","commonSituations":"Mapping states from another system's vocabulary (done/failed/succeeded) directly into the pipeline completion APIs; hand-written state strings in scripts.","solutions":["Use an accepted state string: inprogress, completed, completedwithwarning, or completedwitherror (hyphen/underscore variants also accepted).","Translate foreign state names before calling (e.g., failed -> completedwitherror, done -> completed).","Trim/normalize the incoming string to avoid stray whitespace."],"exampleFix":"// before\nCompleteStep(\"step1\", \"Done\", \"done\");\n// after\nCompleteStep(\"step1\", \"Done\", \"completed\");","handlingStrategy":"validation","validationCode":"var allowed = new HashSet<string>(StringComparer.OrdinalIgnoreCase)\n    { \"inprogress\", \"in_progress\", \"in-progress\", \"completed\", \"completedwithwarning\", \"completed_with_warning\", \"completed-with-warning\", \"completedwitherror\", \"completed_with_error\", \"completed-with-error\" };\nif (!allowed.Contains(completionState))\n{\n    throw new ArgumentException($\"Unknown completion state '{completionState}'.\");\n}","typeGuard":"bool IsKnownCompletionState(string s) => s.ToLowerInvariant() is \"inprogress\" or \"in_progress\" or \"in-progress\" or \"completed\" or \"completedwithwarning\" or \"completedwitherror\";","tryCatchPattern":"try\n{\n    CompleteStep(name, message, completionState);\n}\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"completionState\")\n{\n    CompleteStep(name, message, completionState.Contains(\"error\") ? \"completedwitherror\" : \"completed\");\n}","preventionTips":["Map upstream status enums (done/failed/skipped) to the accepted strings in one place.","Store completion states as the CompletionState enum in code, converting to string only at the boundary."],"tags":["pipeline","enum-parsing","argument-validation"],"backgroundTag":"invalid-enum-value","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"}