dotnet/reactive · error · ArgumentNullException

source4

Error message

source4

What it means

In the 14-source Zip overload the fourth sequence is validated at line 868; a null source4 causes ArgumentNullException with parameter 'source4'. All 14 inputs must be live (or empty) observable sequences for Zip to combine elements element-wise.

Solutions

  1. Supply a valid observable for source4, or Observable.Empty<TSource4>() as a placeholder.
  2. Fix the code path that assigned null to the fourth source variable.
  3. Add a pre-call null check for each of the 14 sources.
  4. Verify no argument drift in the long call site.

Example fix

// before
var zipped = Observable.Zip(s1, s2, s3, null, s5, ..., s14, selector);
// after
var zipped = Observable.Zip(s1, s2, s3, s4 ?? Observable.Empty<TSource4>(), s5, ..., s14, selector);
Defensive patterns

Strategy: validation

Validate before calling

if (source4 == null) throw new ArgumentNullException(nameof(source4));

Type guard

static IObservable<T> NonNull<T>(IObservable<T> s) => s ?? Observable.Empty<T>();

Try / catch

try { var zipped = Observable.Zip(source1, source2, source3, source4, ...); } catch (ArgumentNullException ex) when (ex.ParamName == "source4") { /* substitute default source or abort */ }

Prevention

When it happens

Trigger: Calling the 14-argument Observable.Zip with null in the fourth argument position while other sources are non-null.

Common situations: A telemetry/event stream that was never initialized for feed 4, a null from a lookup keyed by stream name, or a refactor that shifted the null into this position.

Related errors


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

Appendix: source

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

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

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

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

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

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

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

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

            if (source8 == null)

View on GitHub (pinned to 94b5d5ab91)