BCUninstaller/Bulk-Crap-Uninstaller · error · ArgumentException

Value cannot be null or empty

Error message

Value cannot be null or empty

What it means

The Filter(string name, string filterText) constructor validates filterText with string.IsNullOrEmpty and throws ArgumentException (param 'filterText') if it is null or empty. A Filter is a single match rule inside an UninstallList; an empty filter text would match nothing or everything ambiguously, so the constructor rejects it upfront.

Source

Thrown at source/UninstallTools/Lists/Filter.cs:27

using Klocman.Extensions;
using Klocman.Tools;
using UninstallTools.Properties;

namespace UninstallTools.Lists
{
    public class Filter : ITestEntry
    {
        public Filter()
        {
        }

        public Filter(string name, string filterText)
        {
            if (!string.IsNullOrEmpty(name))
                Name = name;

            if (string.IsNullOrEmpty(filterText))
                throw new ArgumentException(Localisation.UninstallListItem_ValueEmpty, nameof(filterText));

            if (filterText.ContainsAny(StringTools.NewLineChars, StringComparison.Ordinal))
                throw new ArgumentException(Localisation.UninstallListItem_NewLineInValue, nameof(filterText));

            ComparisonEntries.Add(new FilterCondition { FilterText = filterText });
        }

        public Filter(string name, bool exclude, params FilterCondition[] conditions)
        {
            if (!string.IsNullOrEmpty(name))
                Name = name;
            Exclude = exclude;
            ComparisonEntries.AddRange(conditions);
        }

        public string Name { get; set; } = Localisation.UninstallListEditor_NewFilter;

        /// <summary>

View on GitHub (pinned to 608321de98)

Solutions

  1. Validate and trim filterText before constructing the Filter; show a validation error to the user if blank.
  2. When loading from XML, skip Filter elements whose text is null/empty rather than passing them to the constructor.
  3. Unit-test the filter-input path with null, empty, and whitespace-only inputs.

Example fix

// before
var filter = new Filter(name, filterText);

// after
if (string.IsNullOrWhiteSpace(filterText))
    throw new InvalidOperationException("Filter text required for filter '" + name + "'.");
var filter = new Filter(name, filterText.Trim());
Defensive patterns

Strategy: validation

Validate before calling

string text = filterText ?? string.Empty;
text = text.Trim();
if (string.IsNullOrEmpty(text))
    throw new InvalidOperationException("Filter text is required.");
var filter = new Filter(name, text);

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Constructing a Filter via 'new Filter(name, filterText)' where filterText is null, string.Empty, or whitespace-only that the caller did not pre-trim. Common when deserialising user-edited XML where a <Filter> element has no text, or when wiring up a filter textbox without validating input.

Common situations: A user saves an uninstall list with a blank filter row; loading it and reconstructing Filter objects throws. Also programmatic creation from a config field that defaults to empty.

Related errors


AI-assisted analysis of BCUninstaller/Bulk-Crap-Uninstaller@608321de98 (2026-08-13). Data as JSON: /api/errors/ac2f8878079d98fb. Report an issue: GitHub.