dotnet/reactive · error · ArgumentNullException

seventh

Error message

seventh

What it means

The 7-source Qbservable.CombineLatest overload throws ArgumentNullException with ParamName "seventh" because the seventh source sequence is null. Rx performs eager argument validation on all seven sources before building the Expression.Call query, so this fails synchronously rather than on subscription.

Solutions

  1. Supply a valid seventh sequence; use Observable.Empty<TSeventh>() if there is genuinely no data
  2. Fix the producer of the seventh source so it never returns null
  3. Guard all arguments with null checks before invoking CombineLatest

Example fix

// before
CombineLatest(q1, s2, s3, s4, s5, s6, seventh); // seventh == null
// after
var seventh = source7 ?? Observable.Empty<SeventhType>();
CombineLatest(q1, s2, s3, s4, s5, s6, seventh);
Defensive patterns

Strategy: validation

Validate before calling

if (seventh == null) seventh = Observable.Empty<TSeventh>();

Type guard

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

Try / catch

try { var q = Qbservable.CombineLatest(first, second, third, fourth, fifth, sixth, seventh); }
catch (ArgumentNullException ex) when (ex.ParamName == "seventh") { /* substitute an empty seventh source */ }

Prevention

When it happens

Trigger: Calling the 7-source IQbservable CombineLatest tuple overload with a null seventh IObservable<TSeventh> argument, e.g. the last stream of a seven-way merge was never constructed or a factory returned null.

Common situations: Composing telemetry/UI/timer streams where the seventh stream comes from an optional service; refactors that grew the pipeline from six to seven sources and forgot to initialize the new one.

Related errors


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

Appendix: source

Thrown at Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.Homoicon.cs:242

        /// <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 IQbservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh)> CombineLatest<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh>(this IQbservable<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 first.Provider.CreateQuery<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh)>(
                Expression.Call(
                    null,
                    new Func<IQbservable<TFirst>, IObservable<TSecond>, IObservable<TThird>, IObservable<TFourth>, IObservable<TFifth>, IObservable<TSixth>, IObservable<TSeventh>, IQbservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh)>>(CombineLatest<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh>).Method,
                    first.Expression,
                    GetSourceExpression(second),
                    GetSourceExpression(third),
                    GetSourceExpression(fourth),
                    GetSourceExpression(fifth),
                    GetSourceExpression(sixth),
                    GetSourceExpression(seventh)
                )
            );
        }

        /// <summary>
        /// Merges the specified observable sequences into one observable sequence of tuple values whenever any of the observable sequences produces an element.

View on GitHub (pinned to 94b5d5ab91)