dotnet/reactive · error · ArgumentNullException

Value cannot be null. (Parameter 'seventh')

Error message

Value cannot be null. (Parameter 'seventh')

What it means

The 7-source Zip overload completes its parameter validation by throwing ArgumentNullException if the seventh observable sequence is null. The exception is raised in the public Zip method before the query is handed to the internal implementation.

Solutions

  1. Return Observable.Empty<TSeventh>() from the factory instead of null when the source is disabled.
  2. Fix the initialization of the seventh source so it is created before the Zip call.
  3. Guard with a null check and fall back to a 6-way Zip overload when the seventh source is absent.
  4. Ensure DI/feature-flag configuration guarantees the seventh stream is registered when this query path runs.

Example fix

// before
var zipped = a.Zip(b, c, d, e, f, analytics?.Events);
// after
var zipped = a.Zip(b, c, d, e, f, analytics?.Events ?? Observable.Empty<TSeventh>());
Defensive patterns

Strategy: validation

Validate before calling

var events = analytics?.Events ?? Observable.Empty<TSeventh>();

Type guard

static bool AnalyticsReady(IObservable<TSeventh>? s) => s is not null;

Try / catch

try { var zipped = a.Zip(b, c, d, e, f, analytics?.Events); }
catch (ArgumentNullException ex) when (ex.ParamName == "seventh") { /* disable analytics path or supply empty source */ }

Prevention

When it happens

Trigger: Calling the 7-tuple Observable.Zip overload (line 1355) with seventh == null; all six preceding null checks passed.

Common situations: The seventh stream comes from an optional dependency (e.g. an analytics provider that is disabled) and its factory returned null; the caller assumed a sequence was always available.

Related errors


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

Appendix: source

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

        /// <param name="seventh">Seventh 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"/> or <paramref name="seventh"/> is null.</exception>
        public static IObservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh)> Zip<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh>(this IObservable<TFirst> first, IObservable<TSecond> second, IObservable<TThird> third, IObservable<TFourth> fourth, IObservable<TFifth> fifth, IObservable<TSixth> sixth, IObservable<TSeventh> seventh)
        {
            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));
            if (seventh == null)
                throw new ArgumentNullException(nameof(seventh));

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

        /// <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>
        /// <typeparam name="TEighth">The type of the elements in the eighth source sequence.</typeparam>
        /// <param name="first">First observable source.</param>
        /// <param name="second">Second observable source.</param>
        /// <param name="third">Third observable source.</param>

View on GitHub (pinned to 94b5d5ab91)