{"record":{"id":"477e7c41d8d0c9ee","repo":"spectreconsole/spectre.console","slug":"task-name-cannot-be-empty-477e7c","errorCode":null,"errorMessage":"Task name cannot be empty.","messagePattern":"Task name cannot be empty\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console/Live/Progress/ProgressTask.cs","lineNumber":216,"sourceCode":"    /// </summary>\n    public int MaxSamplesKept { get; set; } = 1000;\n\n    private void Update(\n        string? description = null,\n        double? maxValue = null,\n        double? increment = null,\n        double? value = null)\n    {\n        lock (_lock)\n        {\n            var startValue = Value;\n\n            if (description != null)\n            {\n                description = description?.RemoveNewLines()?.Trim();\n                if (string.IsNullOrWhiteSpace(description))\n                {\n                    throw new InvalidOperationException(\"Task name cannot be empty.\");\n                }\n\n                _description = description;\n            }\n\n            if (maxValue != null)\n            {\n                _maxValue = maxValue.Value;\n            }\n\n            if (increment != null)\n            {\n                _value += increment.Value;\n            }\n\n            if (value != null)\n            {\n                _value = value.Value;","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console/Live/Progress/ProgressTask.cs#L198-L234","documentation":"Thrown by the internal ProgressTask.Update method when the description parameter is non-null but becomes empty after RemoveNewLines and Trim. Update is called by the public Description setter (and Increment/UpdateValue). Unlike the constructor (which throws ArgumentException), this path throws InvalidOperationException. The check ensures a task's description can never become blank after construction.","triggerScenarios":"Setting task.Description = \"   \" or task.Description = \"\"; calling any API that delegates to Update with a whitespace-only description string. This includes ProgressTask.Increment when description is passed, though Increment only passes increment.","commonSituations":"Dynamically updating a task description from live data that becomes empty; user input or config driving Description that wasn't sanitized; clearing a description intentionally (not supported by design).","solutions":["Validate non-whitespace before assigning task.Description.","Keep the old description if the new one is empty: if (!string.IsNullOrWhiteSpace(newDesc)) task.Description = newDesc;","Sanitize upstream data so blank strings never reach the Description setter."],"exampleFix":"// before\ntask.Description = newName; // newName may be \"   \"\n\n// after\nif (!string.IsNullOrWhiteSpace(newName))\n{\n    task.Description = newName;\n}","handlingStrategy":"validation","validationCode":"// Validate before updating description\nif (!string.IsNullOrWhiteSpace(newDescription))\n{\n    task.Description = newDescription;\n}","typeGuard":"static bool IsValidTaskDescription(string? description)\n    => !string.IsNullOrWhiteSpace(description);","tryCatchPattern":null,"preventionTips":["Always check IsNullOrWhiteSpace before assigning task.Description.","Sanitize dynamic description sources upstream.","Keep the previous description when the new one is empty."],"tags":["invalidoperationexception","progress","progress-task","validation","empty-string"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}