{"record":{"id":"3bde2bd976a6cadd","repo":"abpframework/abp","slug":"job-names-cannot-be-empty-when-the-filter-mode-is","errorCode":null,"errorMessage":"Job names cannot be empty when the filter mode is Include or Exclude.","messagePattern":"Job names cannot be empty when the filter mode is Include or Exclude\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobNameFilter.cs","lineNumber":39,"sourceCode":"    public IReadOnlyList<string> JobNames { get; }\n\n    public BackgroundJobNameFilter(BackgroundJobNameFilterMode mode, IReadOnlyList<string>? jobNames = null)\n    {\n        if (!Enum.IsDefined(typeof(BackgroundJobNameFilterMode), mode))\n        {\n            throw new ArgumentException($\"Invalid background job name filter mode: {mode}\", nameof(mode));\n        }\n\n        var names = jobNames?.Where(x => !x.IsNullOrWhiteSpace()).Distinct(StringComparer.Ordinal).ToList() ?? new List<string>();\n\n        if (mode == BackgroundJobNameFilterMode.None && names.Count > 0)\n        {\n            throw new ArgumentException(\"Job names must be empty when the filter mode is None.\", nameof(jobNames));\n        }\n\n        if (mode != BackgroundJobNameFilterMode.None && names.Count == 0)\n        {\n            throw new ArgumentException(\"Job names cannot be empty when the filter mode is Include or Exclude.\", nameof(jobNames));\n        }\n\n        Mode = mode;\n        JobNames = names.AsReadOnly();\n    }\n\n    public static BackgroundJobNameFilter Include(IReadOnlyList<string> jobNames)\n    {\n        return new BackgroundJobNameFilter(BackgroundJobNameFilterMode.Include, jobNames);\n    }\n\n    public static BackgroundJobNameFilter Exclude(IReadOnlyList<string> jobNames)\n    {\n        return new BackgroundJobNameFilter(BackgroundJobNameFilterMode.Exclude, jobNames);\n    }\n\n    /// <summary>\n    /// Whether the given job name passes this filter, using an ordinal (case-sensitive) comparison for the","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobNameFilter.cs#L21-L57","documentation":"Thrown by the BackgroundJobNameFilter constructor when mode is Include or Exclude but the jobNames list is empty after filtering out whitespace/null entries. Include/Exclude need at least one name to be meaningful, so an empty list is rejected as a programmer error.","triggerScenarios":"Constructing new BackgroundJobNameFilter(BackgroundJobNameFilterMode.Include, new List<string>()) or passing only whitespace/null entries with mode Include or Exclude.","commonSituations":"Building a filter from a query/result that returned zero job names; passing a list before it was populated; deserialization that yielded empty names but a non-None mode; leftover default empty list.","solutions":["Ensure at least one non-whitespace job name is supplied for Include/Exclude filters.","If you genuinely want 'all jobs', use BackgroundJobNameFilterMode.None (or the None property) instead.","Validate that the names source is non-empty before constructing the filter.","Use the static Include(...) / Exclude(...) factories and guard against empty input."],"exampleFix":"// before\nvar f = new BackgroundJobNameFilter(BackgroundJobNameFilterMode.Include, names); // names empty -> throws\n// after\nvar f = names.Count == 0\n    ? BackgroundJobNameFilter.None\n    : BackgroundJobNameFilter.Include(names);","handlingStrategy":"validation","validationCode":"var clean = names?.Where(n => !n.IsNullOrWhiteSpace()).ToList() ?? new();\nif (mode != BackgroundJobNameFilterMode.None && clean.Count == 0)\n{\n    /* use None, or ensure at least one name before constructing */\n}","typeGuard":"null","tryCatchPattern":"try { var f = new BackgroundJobNameFilter(mode, names); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"cannot be empty when the filter mode is Include or Exclude\"))\n{ /* fall back to None, or populate names */ }","preventionTips":["Use Include(...)/Exclude(...) factories and guard against empty input.","Verify the names source is non-empty before constructing Include/Exclude filters.","Fall back to None when no names are available.","Unit-test filter construction around empty/whitespace name lists."],"tags":["background-jobs","abp","validation","configuration"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}