dotnet/reactive · error · ArgumentNullException

source11

Error message

source11

What it means

System.ArgumentNullException thrown by the 14-source public Zip overload in Observable.Multiple.Zip.cs when the eleventh source sequence (source11) is null. Zip subscribes to every input sequence concurrently and emits only complete element groups, so any null input would break its internal zipper state machine. The library eagerly validates each argument and throws before creating the observable.

Solutions

  1. Pass a real observable as the eleventh argument; initialize it before the Zip call.
  2. Substitute Observable.Empty<T>() when that source is legitimately absent.
  3. Null-check each source (e.g. ArgumentNullException.ThrowIfNull(s11)) before calling Zip.
  4. Prefer the array/params overload Observable.Zip(sources, resultSelector) and validate the collection contains no nulls.

Example fix

// before
var zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, selector); // s11 == null
// after
var zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11 ?? Observable.Empty<decimal>(), s12, s13, s14, selector);
Defensive patterns

Strategy: validation

Validate before calling

if (s11 is null) throw new ArgumentNullException(nameof(s11));

Type guard

static bool IsValidSource<T>(IObservable<T>? s) => s is not null;

Try / catch

try { var zipped = Observable.Zip(s1, ..., s11, ..., s14, selector); } catch (ArgumentNullException ex) when (ex.ParamName == "source11") { // log and fall back to a default stream }

Prevention

When it happens

Trigger: Calling Observable.Zip(s1, ..., s11, ..., s14, resultSelector) where the eleventh argument is a null IObservable reference; all other sources and resultSelector are non-null.

Common situations: An event stream for slot 11 that is only created behind a feature flag or configuration toggle, leaving null when the feature is off; a factory method returning null instead of a cold observable; migrating code that previously used a different overload and misaligned positional arguments.

Related errors


AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15). Data as JSON: /api/errors/26b2690a60b1fb4b. Report an issue: GitHub.

Appendix: source

Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs:903

            if (source8 == null)
            {
                throw new ArgumentNullException(nameof(source8));
            }

            if (source9 == null)
            {
                throw new ArgumentNullException(nameof(source9));
            }

            if (source10 == null)
            {
                throw new ArgumentNullException(nameof(source10));
            }

            if (source11 == null)
            {
                throw new ArgumentNullException(nameof(source11));
            }

            if (source12 == null)
            {
                throw new ArgumentNullException(nameof(source12));
            }

            if (source13 == null)
            {
                throw new ArgumentNullException(nameof(source13));
            }

            if (source14 == null)
            {
                throw new ArgumentNullException(nameof(source14));
            }

            if (resultSelector == null)

View on GitHub (pinned to 94b5d5ab91)