{"record":{"id":"b5e829767e4dba77","repo":"abpframework/abp","slug":"job-args-types-cannot-contain-null-b5e829","errorCode":null,"errorMessage":"Job args types cannot contain null.","messagePattern":"Job args types cannot contain null\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorkerConfiguration.cs","lineNumber":32,"sourceCode":"    /// It is used to serialize the worker across application instances when\n    /// <see cref=\"AbpBackgroundJobWorkerOptions.MaxParallelJobExecutionCount\"/> is 1; in parallel mode\n    /// (greater than 1) jobs are claimed with per-job locks instead and this lock is not acquired.\n    /// </summary>\n    public string LockName { get; }\n\n    /// <summary>\n    /// The job argument types that are processed exclusively by this worker.\n    /// </summary>\n    public IReadOnlyList<Type> JobArgsTypes { get; }\n\n    public BackgroundJobWorkerConfiguration(string lockName, params Type[] jobArgsTypes)\n    {\n        LockName = Check.NotNullOrWhiteSpace(lockName, nameof(lockName));\n        Check.NotNullOrEmpty(jobArgsTypes, nameof(jobArgsTypes));\n\n        if (jobArgsTypes.Any(t => t == null))\n        {\n            throw new ArgumentException(\"Job args types cannot contain null.\", nameof(jobArgsTypes));\n        }\n\n        JobArgsTypes = jobArgsTypes.ToList();\n    }\n}\n","sourceCodeStart":14,"sourceCodeEnd":38,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorkerConfiguration.cs#L14-L38","documentation":"Thrown by the BackgroundJobWorkerConfiguration constructor when one of the elements in the jobArgsTypes array is null. The configuration rejects null elements because a dedicated worker must be bound to concrete job argument types to filter and claim jobs. This is an ArgumentException raised at configuration time, before any worker starts.","triggerScenarios":"Calling the non-generic AddDedicatedWorker(string lockName, params Type[] jobArgsTypes) overload on AbpBackgroundJobWorkerOptions and passing a Type[] array that contains at least one null element (e.g. new Type[] { typeof(MyJobArgs), null }). The generic overloads (AddDedicatedWorker<TArgs>) cannot produce this because typeof(TArgs) is never null.","commonSituations":"Building a Type[] dynamically from a collection of types where one entry resolved to null (e.g. a Type.GetType(string) call that returned null for an unrecognized name). Reflecting job types from an assembly where a type-load failure silently yields null. Copying a list that was not filtered for nulls before passing it to AddDedicatedWorker.","solutions":["Filter the Type[] array for nulls before calling AddDedicatedWorker: jobArgsTypes.Where(t => t != null).ToArray().","Use the strongly-typed generic overloads (AddDedicatedWorker<TArgs>, AddDedicatedWorker<TArgs1, TArgs2>) which cannot introduce null elements.","Debug the source of the null entry (e.g. log Type.GetType(name) results) and fix the lookup so it never returns null for expected job types."],"exampleFix":"// before\nvar types = names.Select(Type.GetType).ToArray();\noptions.AddDedicatedWorker(\"lock\", types);\n\n// after\nvar types = names\n    .Select(Type.GetType)\n    .Where(t => t != null)\n    .ToArray();\nif (types.Length != names.Count) throw new InvalidOperationException(\"One or more job types could not be resolved.\");\noptions.AddDedicatedWorker(\"lock\", types);","handlingStrategy":"validation","validationCode":"Type[] jobArgsTypes = ResolveTypes();\nif (jobArgsTypes.Any(t => t == null))\n{\n    throw new InvalidOperationException(\"jobArgsTypes contains a null entry; resolve before calling AddDedicatedWorker.\");\n}\noptions.AddDedicatedWorker(lockName, jobArgsTypes);","typeGuard":"static bool HasNoNulls(Type[] types) => types != null && types.All(t => t != null);","tryCatchPattern":null,"preventionTips":["Prefer the generic AddDedicatedWorker<TArgs> overloads, which cannot produce null elements.","When building Type[] from Type.GetType(string) or reflection, filter out nulls and log unresolved names.","Unit-test your configuration-building code with edge-case inputs that may yield null types."],"tags":["background-jobs","configuration","argument-validation","null-check"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}