dotnet/reactive · error · ArgumentNullException

ninth

Error message

ninth

What it means

This ArgumentNullException is thrown by the Qbservable.CombineLatest 9-source overload when the ninth source sequence (ninth) is null. It is the last guard in the method; the throw fires synchronously at composition time, before any subscription occurs.

Solutions

  1. Pass a non-null IObservable<TNinth> as the ninth argument
  2. Substitute Observable.Empty<TNinth>() or Observable.Never<TNinth>() when the source is optional
  3. Ensure the factory/config path that supplies the ninth stream returns a valid sequence
  4. Catch ArgumentNullException and inspect ParamName to identify which source was null

Example fix

// before
var q = q1.CombineLatest(o2, o3, o4, o5, o6, o7, o8, GetNinth()); // GetNinth() == null
// after
var ninth = GetNinth() ?? Observable.Empty<TNinth>();
var q = q1.CombineLatest(o2, o3, o4, o5, o6, o7, o8, ninth);
Defensive patterns

Strategy: validation

Validate before calling

if (ninth is null)
    throw new ArgumentException("ninth source must be non-null");

Type guard

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

Try / catch

try
{
    var q = q1.CombineLatest(o2, o3, o4, o5, o6, o7, o8, ninth);
}
catch (ArgumentNullException ex) when (ex.ParamName == "ninth")
{
    logger.LogError(ex, "ninth source of CombineLatest is null");
}

Prevention

When it happens

Trigger: Calling CombineLatest(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth) with ninth == null, commonly when the ninth stream comes from a late-bound service, config-driven factory, or conditional expression returning null.

Common situations: Typical when a newly added source (e.g. an analytics or audit stream) is disabled by configuration and the code still passes the (null) stream reference into the composition.

Related errors


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

Appendix: source

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

        {
            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));
            if (eighth == null)
                throw new ArgumentNullException(nameof(eighth));
            if (ninth == null)
                throw new ArgumentNullException(nameof(ninth));

            return first.Provider.CreateQuery<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth)>(
                Expression.Call(
                    null,
                    new Func<IQbservable<TFirst>, IObservable<TSecond>, IObservable<TThird>, IObservable<TFourth>, IObservable<TFifth>, IObservable<TSixth>, IObservable<TSeventh>, IObservable<TEighth>, IObservable<TNinth>, IQbservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth)>>(CombineLatest<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth>).Method,
                    first.Expression,
                    GetSourceExpression(second),
                    GetSourceExpression(third),
                    GetSourceExpression(fourth),
                    GetSourceExpression(fifth),
                    GetSourceExpression(sixth),
                    GetSourceExpression(seventh),
                    GetSourceExpression(eighth),
                    GetSourceExpression(ninth)
                )
            );
        }

View on GitHub (pinned to 94b5d5ab91)