dotnet/reactive · error · ArgumentNullException

Value cannot be null. (Parameter 'source13')

Error message

Value cannot be null. (Parameter 'source13')

What it means

This ArgumentNullException is thrown by the 13-source Observable.Zip overload when the 13th (last) observable source (source13) is null. Rx validates all sources and the resultSelector synchronously before building the query, reporting the exact null parameter name so the bad argument is easy to locate.

Solutions

  1. Trace the 13th argument and ensure its producer returns a non-null IObservable<TSource13>.
  2. Substitute Observable.Empty<TSource13>() (Zip completes) or Observable.Never<TSource13>() (Zip waits) when the source is optional.
  3. Guard the call with ArgumentNullException.ThrowIfNull(source13) before invoking Zip.
  4. For long source lists, build and validate a List<IObservable<T>> and use the IEnumerable-based Zip overload to avoid positional mistakes.

Example fix

// before
var zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, lastStream, (a, b, c, d, e, f, g, h, i, j, k, l, m) => a + m);

// after
var s13 = lastStream ?? Observable.Empty<int>();
var zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, (a, b, c, d, e, f, g, h, i, j, k, l, m) => a + m);
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

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

Try / catch

try
{
    var zipped = Observable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, result);
}
catch (ArgumentNullException ex) when (ex.ParamName == nameof(s13))
{
    logger.LogError(ex, "Zip source13 was null");
}

Prevention

When it happens

Trigger: Calling Observable.Zip(source1, ..., source12, null, resultSelector) with a null IObservable<TSource13> in the 13th positional slot (immediately before the resultSelector).

Common situations: The last stream in a long positional list was dropped or misordered during a refactor, shifting null into the source13 slot; an optional source was passed without a default; a builder that skipped the final channel.

Related errors


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

Appendix: source

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

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

            return s_impl.Zip(source1, source2, source3, source4, source5, source6, source7, source8, source9, source10, source11, source12, source13, 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>
        /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
        /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
        /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
        /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
        /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>

View on GitHub (pinned to 94b5d5ab91)