dotnetcore/CAP · error · ArgumentNullException

Value cannot be null. (Parameter 'configure')

Error message

Value cannot be null. (Parameter 'configure')

What it means

ArgumentNullException on the 'configure' parameter: the UseKafka(CapOptions, Action<KafkaOptions>) overload was called with a null configuration delegate. This is a generic null-guard sentinel; the faulting input is the configure lambda the caller passed (or failed to pass).

Solutions

  1. Pass a non-null lambda: services.AddCap(options => options.UseKafka(opt => opt.Servers = "host:9092"))
  2. Use the string overload UseKafka(options, bootstrapServers) which builds the delegate for you
  3. Do not resolve/invoke UseKafka with a variable that may be null; default to opt => { }
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs:30 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dotnetcore/CAP@e52b8508e5 (2026-09-14). Data as JSON: /api/errors/14dc04ca6e3446eb. Report an issue: GitHub.

Appendix: source

Thrown at src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs:30

    /// <summary>
    /// Configuration to use kafka in CAP.
    /// </summary>
    /// <param name="options">CAP configuration options</param>
    /// <param name="bootstrapServers">Kafka bootstrap server urls.</param>
    public static CapOptions UseKafka(this CapOptions options, string bootstrapServers)
    {
        return options.UseKafka(opt => { opt.Servers = bootstrapServers; });
    }

    /// <summary>
    /// Configuration to use kafka in CAP.
    /// </summary>
    /// <param name="options">CAP configuration options</param>
    /// <param name="configure">Provides programmatic configuration for the kafka .</param>
    /// <returns></returns>
    public static CapOptions UseKafka(this CapOptions options, Action<KafkaOptions> configure)
    {
        if (configure == null) throw new ArgumentNullException(nameof(configure));

        options.RegisterExtension(new KafkaCapOptionsExtension(configure));

        return options;
    }
}

View on GitHub (pinned to e52b8508e5)