dotnet/reactive · error · ArgumentNullException

source13

Error message

source13

What it means

System.ArgumentNullException thrown by the 14-source public Zip overload in Observable.Multiple.Zip.cs when the thirteenth source sequence (source13) is null. The operator performs eager null validation on every source parameter in order, so a null source13 aborts the call before an observable pipeline is even constructed. This keeps failures deterministic and close to the offending call site.

Solutions

  1. Supply a valid observable for source13 before invoking Zip.
  2. Fall back to Observable.Empty<T>() if the stream may legitimately be absent.
  3. Validate all inputs up front (e.g. EnsureAllNonNull(sources)) so you fail with your own message.
  4. Refactor to Observable.Zip(new[] {...}, resultSelector) to avoid positional null slots and make sources enumerable/checkable.

Example fix

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

Strategy: validation

Validate before calling

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

Type guard

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

Try / catch

try { var zipped = Observable.Zip(s1, ..., s13, ..., s14, selector); } catch (ArgumentNullException ex) when (ex.ParamName == "source13") { // substitute fallback stream and re-compose }

Prevention

When it happens

Trigger: Calling Observable.Zip(s1, ..., s13, ..., s14, resultSelector) where the thirteenth argument is a null IObservable reference while other arguments are valid.

Common situations: One of many sensor/market-data streams failing to initialize (e.g. device offline, connection never established and the field left null); a test setup that stubbed all but one source; accidental argument reorder after adding a new source to the chain.

Related errors


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

Appendix: source

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

            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)
            {
                throw new ArgumentNullException(nameof(resultSelector));
            }

            return s_impl.Zip(source1, source2, source3, source4, source5, source6, source7, source8, source9, source10, source11, source12, source13, source14, resultSelector);
        }

        /// <summary>
        /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
        /// </summary>

View on GitHub (pinned to 94b5d5ab91)