{"record":{"id":"7b56269b123db7ab","repo":"dotnetcore/CAP","slug":"value-cannot-be-null-parameter-topicnames-7b5626","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'topicNames')","messagePattern":"Value cannot be null\\. \\(Parameter 'topicNames'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs","lineNumber":48,"sourceCode":"    public KafkaConsumerClient(string groupId, byte groupConcurrent,\n        IOptions<KafkaOptions> options, IServiceProvider serviceProvider)\n    {\n        _groupId = groupId;\n        _groupConcurrent = groupConcurrent;\n        _semaphore = new SemaphoreSlim(groupConcurrent);\n        _serviceProvider = serviceProvider;\n        _kafkaOptions = options.Value ?? throw new ArgumentNullException(nameof(options));\n    }\n\n    public Func<TransportMessage, object?, Task>? OnMessageCallback { get; set; }\n\n    public Action<LogMessageEventArgs>? OnLogCallback { get; set; }\n\n    public BrokerAddress BrokerAddress => new(\"kafka\", _kafkaOptions.Servers);\n\n    public async Task<ICollection<string>> FetchTopicsAsync(IEnumerable<string> topicNames)\n    {\n        if (topicNames == null) throw new ArgumentNullException(nameof(topicNames));\n\n        var regexTopicNames = topicNames.Select(Helper.WildcardToRegex).ToList();\n\n        var allowAutoCreate = true;\n        if (_kafkaOptions.MainConfig.TryGetValue(\"allow.auto.create.topics\", out var autoCreateValue)\n            && bool.TryParse(autoCreateValue, out var parsedValue))\n        {\n            allowAutoCreate = parsedValue;\n        }\n\n        if (allowAutoCreate)\n        {\n            try\n            {\n                var config = new AdminClientConfig(_kafkaOptions.MainConfig)\n                { BootstrapServers = _kafkaOptions.Servers };\n\n                using var adminClient = new AdminClientBuilder(config).Build();","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/dotnetcore/CAP/blob/e52b8508e54cdb7a9ce7f9fec03d9ea8ad2710fb/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs#L30-L66","documentation":"ArgumentNullException on 'topicNames' raised inside FetchTopicsAsync's topic-creation path (the guard shown in the constructor context is the pattern reused for topic collections): the sequence of topic names passed to the Kafka admin/client call was null, so metadata for topics could not be fetched. The faulting input is the topics collection supplied to the subscribe/fetch flow.","triggerScenarios":"Thrown at src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs:48 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the topic list passed to SubscribeAsync/FetchTopicsAsync is non-null (default to an empty list)","Register topics via CAP attributes/configuration so the list is always populated before subscription","Null-coalesce at the call site: topics ?? Array.Empty<string>()"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e52b8508e54cdb7a9ce7f9fec03d9ea8ad2710fb","analyzedAt":"2026-09-14T14:46:34.677Z","contentChangedAt":"2026-09-14T14:46:34.677Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}