dotnet/reactive · error · ArgumentNullException

Value cannot be null. (Parameter 'sixth')

Error message

Value cannot be null. (Parameter 'sixth')

What it means

The six-source Zip overload throws ArgumentNullException when any of its six observable arguments is null; this error reports the sixth argument being null. The validation happens synchronously in the public Zip method at Observable.Multiple.Zip.cs:1316, so the call fails immediately and never returns an observable. Rx enforces this contract to prevent deferred failures inside the query.

Solutions

  1. Fix the construction of the sixth observable so it is non-null before the Zip call.
  2. Substitute Observable.Empty<TSixth>() when the source is intentionally absent.
  3. Guard the argument at the call site with ArgumentNullException.ThrowIfNull to fail with clearer context.
  4. Enable nullable reference types and mark the source as nullable so the compiler surfaces the issue before runtime.

Example fix

// before
var zipped = Observable.Zip(a, b, c, d, e, sixth); // sixth == null

// after
var zipped = Observable.Zip(a, b, c, d, e, sixth ?? Observable.Empty<TSixth>());
Defensive patterns

Strategy: validation

Validate before calling

if (sixth is null)
    throw new InvalidOperationException("Sixth Zip source is null; ensure the sixth observable stream is initialized before zipping.");

Type guard

static bool HasSixthSource<T6>(IObservable<T6> sixth) => sixth is not null;

Try / catch

try
{
    zipped = Observable.Zip(first, second, third, fourth, fifth, sixth);
}
catch (ArgumentNullException ex) when (ex.ParamName == "sixth")
{
    zipped = Observable.Zip(first, second, third, fourth, fifth, Observable.Empty<TSixth>());
}

Prevention

When it happens

Trigger: Calling Observable.Zip(first, second, third, fourth, fifth, sixth) with the sixth IObservable<TSixth> argument null — e.g. a subject never initialized, a method returning null for a missing stream, or a config-driven source not created.

Common situations: Combining six UI/event streams where the last source is optional and left null; pipeline code where a late-added sixth source isn't wired in older code paths; DI containers missing a registration for the sixth stream.

Related errors


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

Appendix: source

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

        /// <param name="fourth">Fourth observable source.</param>
        /// <param name="fifth">Fifth observable source.</param>
        /// <param name="sixth">Sixth observable source.</param>
        /// <returns>An observable sequence containing the result of combining elements of the sources using tuple values.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="first"/> or <paramref name="second"/> or <paramref name="third"/> or <paramref name="fourth"/> or <paramref name="fifth"/> or <paramref name="sixth"/> is null.</exception>
        public static IObservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth)> Zip<TFirst, TSecond, TThird, TFourth, TFifth, TSixth>(this IObservable<TFirst> first, IObservable<TSecond> second, IObservable<TThird> third, IObservable<TFourth> fourth, IObservable<TFifth> fifth, IObservable<TSixth> sixth)
        {
            if (first == null)
                throw new ArgumentNullException(nameof(first));
            if (second == null)
                throw new ArgumentNullException(nameof(second));
            if (third == null)
                throw new ArgumentNullException(nameof(third));
            if (fourth == null)
                throw new ArgumentNullException(nameof(fourth));
            if (fifth == null)
                throw new ArgumentNullException(nameof(fifth));
            if (sixth == null)
                throw new ArgumentNullException(nameof(sixth));

            return s_impl.Zip(first, second, third, fourth, fifth, sixth);
        }

        /// <summary>
        /// Merges the specified observable sequences into one observable sequence of tuple values whenever all of the observable sequences have produced an element at a corresponding index.
        /// </summary>
        /// <typeparam name="TFirst">The type of the elements in the first source sequence.</typeparam>
        /// <typeparam name="TSecond">The type of the elements in the second source sequence.</typeparam>
        /// <typeparam name="TThird">The type of the elements in the third source sequence.</typeparam>
        /// <typeparam name="TFourth">The type of the elements in the fourth source sequence.</typeparam>
        /// <typeparam name="TFifth">The type of the elements in the fifth source sequence.</typeparam>
        /// <typeparam name="TSixth">The type of the elements in the sixth source sequence.</typeparam>
        /// <typeparam name="TSeventh">The type of the elements in the seventh source sequence.</typeparam>
        /// <param name="first">First observable source.</param>
        /// <param name="second">Second observable source.</param>
        /// <param name="third">Third observable source.</param>
        /// <param name="fourth">Fourth observable source.</param>

View on GitHub (pinned to 94b5d5ab91)