dotnet/reactive · error · ArgumentNullException

Value cannot be null. (Parameter 'source9')

Error message

Value cannot be null. (Parameter 'source9')

What it means

The 9-source CombineLatest overload throws ArgumentNullException with Parameter 'source9' when the final (ninth) source observable is null. This is the last source check before the resultSelector check; it fires synchronously at the call site before any subscription occurs.

Solutions

  1. Assign a real IObservable<TSource9> to the ninth argument before the call.
  2. Use Observable.Empty<TSource9>() if the stream can legitimately be absent.
  3. Fix whatever producer returned null for that stream.
  4. Validate all nine sources in one guard method before composition.

Example fix

// before
var combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, s8, tail, sel); // tail == null
// after
var combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, s8, tail ?? Observable.Empty<int>(), sel);
Defensive patterns

Strategy: validation

Validate before calling

if (tail == null) tail = Observable.Empty<TSource9>();

Type guard

bool Ready<T>([NotNullWhen(true)] IObservable<T>? s) => s is not null;

Try / catch

try { var c = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, s8, s9, sel); }
catch (ArgumentNullException ex) when (ex.ParamName == "source9") { /* wire the missing stream and retry */ }

Prevention

When it happens

Trigger: Passing null as the ninth argument of Observable.CombineLatest — e.g. a stream built from a nullable return value or a dictionary/config miss for the last source.

Common situations: The last source is often added later during refactors and its wiring is forgotten; telemetry or signal streams that are null when instrumentation is off.

Related errors


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

Appendix: source

Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs:420

            if (source6 == null)
            {
                throw new ArgumentNullException(nameof(source6));
            }

            if (source7 == null)
            {
                throw new ArgumentNullException(nameof(source7));
            }

            if (source8 == null)
            {
                throw new ArgumentNullException(nameof(source8));
            }

            if (source9 == null)
            {
                throw new ArgumentNullException(nameof(source9));
            }

            if (resultSelector == null)
            {
                throw new ArgumentNullException(nameof(resultSelector));
            }

            return s_impl.CombineLatest(source1, source2, source3, source4, source5, source6, source7, source8, source9, resultSelector);
        }

        /// <summary>
        /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
        /// </summary>
        /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
        /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
        /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
        /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
        /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>

View on GitHub (pinned to 94b5d5ab91)