dotnet/reactive · error · ArgumentNullException

fifth

Error message

fifth

What it means

Thrown by the 5-ary CombineLatest overload when the fifth (last) source sequence is null. This is the final guard in the method's validation chain before first.Provider.CreateQuery builds the combine expression. Null is not a valid stand-in for an empty or never-completing sequence in the Qbservable model.

Solutions

  1. Pass a valid IObservable<TFifth> (Observable.Empty or Observable.Never if no data is expected).
  2. Fix the producer that returned null for the fifth sequence.
  3. Coalesce the argument before calling CombineLatest.

Example fix

// before
var combined = first.CombineLatest(s2, s3, s4, fifth); // fifth null
// after
var combined = first.CombineLatest(s2, s3, s4, fifth ?? Observable.Empty<TFifth>());
Defensive patterns

Strategy: validation

Validate before calling

if (fifth == null) fifth = Observable.Empty<TFifth>();

Type guard

static bool IsObservableSet<T>(IObservable<T> source) => source != null;

Try / catch

try { var combined = first.CombineLatest(second, third, fourth, fifth); } catch (ArgumentNullException ex) when (ex.ParamName == "fifth") { logger.LogError(ex, "Null fifth source passed to 5-ary CombineLatest"); }

Prevention

When it happens

Trigger: Calling first.CombineLatest(second, third, fourth, fifth) with fifth == null, e.g. a trailing optional stream that was never created.

Common situations: Feature-flagged last stream missing at runtime; array/list of sources indexed out to a null element; tests invoking the overload with only some arguments set.

Related errors


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

Appendix: source

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

        /// <param name="second">Second observable source.</param>
        /// <param name="third">Third observable source.</param>
        /// <param name="fourth">Fourth observable source.</param>
        /// <param name="fifth">Fifth 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" /> is null.</exception>
        public static IQbservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth)> CombineLatest<TFirst, TSecond, TThird, TFourth, TFifth>(this IQbservable<TFirst> first, IObservable<TSecond> second, IObservable<TThird> third, IObservable<TFourth> fourth, IObservable<TFifth> fifth)
        {
            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));

            return first.Provider.CreateQuery<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth)>(
                Expression.Call(
                    null,
                    new Func<IQbservable<TFirst>, IObservable<TSecond>, IObservable<TThird>, IObservable<TFourth>, IObservable<TFifth>, IQbservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth)>>(CombineLatest<TFirst, TSecond, TThird, TFourth, TFifth>).Method,
                    first.Expression,
                    GetSourceExpression(second),
                    GetSourceExpression(third),
                    GetSourceExpression(fourth),
                    GetSourceExpression(fifth)
                )
            );
        }

        /// <summary>
        /// Merges the specified observable sequences into one observable sequence of tuple values whenever any of the observable sequences produces an element.
        /// </summary>
        /// <typeparam name="TFirst">The type of the elements in the first source sequence.</typeparam>

View on GitHub (pinned to 94b5d5ab91)