{"record":{"id":"41b38c531e6d0f80","repo":"spectreconsole/spectre.console","slug":"task-name-cannot-be-empty","errorCode":null,"errorMessage":"Task name cannot be empty","messagePattern":"Task name cannot be empty","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console/Live/Progress/ProgressTask.cs","lineNumber":142,"sourceCode":"    /// </summary>\n    /// <param name=\"id\">The task ID.</param>\n    /// <param name=\"description\">The task description.</param>\n    /// <param name=\"maxValue\">The task max value.</param>\n    /// <param name=\"autoStart\">Whether or not the task should start automatically.</param>\n    /// <param name=\"timeProvider\">The time provider to use. Defaults to <see cref=\"TimeProvider.System\"/>.</param>\n    public ProgressTask(int id, string description, double maxValue, bool autoStart = true, TimeProvider? timeProvider = null)\n    {\n        lazySamples = new(() => new CircularBuffer<ProgressSample>(MaxSamplesKept) { UniqueRemovedCheck = false });\n        _lock = new object();\n        _timeProvider = timeProvider ?? TimeProvider.System;\n        _maxValue = maxValue;\n        _value = 0;\n        _description = description?.RemoveNewLines()?.Trim() ??\n                       throw new ArgumentNullException(nameof(description));\n\n        if (string.IsNullOrWhiteSpace(_description))\n        {\n            throw new ArgumentException(\"Task name cannot be empty\", nameof(description));\n        }\n\n        Id = id;\n        State = new ProgressTaskState();\n        StartTime = autoStart ? _timeProvider.GetLocalNow().LocalDateTime : null;\n    }\n\n    /// <summary>\n    /// Starts the task.\n    /// </summary>\n    public void StartTask()\n    {\n        lock (_lock)\n        {\n            if (StopTime != null)\n            {\n                throw new InvalidOperationException(\"Stopped tasks cannot be restarted\");\n            }","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console/Live/Progress/ProgressTask.cs#L124-L160","documentation":"Thrown by the ProgressTask constructor when the description parameter, after RemoveNewLines and Trim, is null or whitespace. The null check on description itself throws ArgumentNullException separately; this ArgumentException fires when description is a non-null string that becomes empty after trimming (e.g., \"   \", \"\\n\\t\", or \"\"). Every ProgressTask must have a visible, non-empty description for rendering.","triggerScenarios":"Creating new ProgressTask(id, \"   \", 100) or new ProgressTask(id, \"\", 100); also new ProgressTask(id, \"\\n\\n\", 100). Calling AnsiConsole.Progress().Start(ctx => ctx.AddTask(\"  \")) hits this same constructor.","commonSituations":"Description sourced from user input, config, or data that wasn't validated for whitespace; dynamically generated names from data that produces empty strings; copy-paste leaving a placeholder empty string in AddTask.","solutions":["Validate the description string is non-whitespace before constructing the ProgressTask or calling AddTask.","Provide a fallback description when the source data is empty: var desc = string.IsNullOrWhiteSpace(name) ? \"Unnamed task\" : name;","Sanitize input upstream so empty descriptions never reach the progress API."],"exampleFix":"// before\nvar task = ctx.AddTask(userInput); // userInput may be \"   \"\n\n// after\nvar desc = string.IsNullOrWhiteSpace(userInput) ? \"Processing\" : userInput;\nvar task = ctx.AddTask(desc);","handlingStrategy":"validation","validationCode":"// Sanitize description before creating task\nvar desc = string.IsNullOrWhiteSpace(description)\n    ? \"Unnamed task\"\n    : description.Trim();\nvar task = new ProgressTask(id, desc, maxValue);","typeGuard":"static bool IsValidTaskDescription(string? description)\n    => !string.IsNullOrWhiteSpace(description);","tryCatchPattern":null,"preventionTips":["Validate description for non-whitespace before AddTask or new ProgressTask.","Provide a fallback name when the source data is empty.","Sanitize user input upstream so blank strings never reach the progress API."],"tags":["argumentexception","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"}