dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'third')
Error message
Value cannot be null. (Parameter 'third')
What it means
The tuple-based nine-source CombineLatest overload validates its arguments sequentially and throws ArgumentNullException with parameter name 'third' when the third observable is null. This fail-fast check exists so composition errors surface at the call site instead of causing NullReferenceException inside the operator later. It is a documented precondition of the method.
Solutions
- Provide a valid IObservable<TThird> instance for the third argument
- Use Observable.Empty<TThird>() or Observable.Never<TThird>() when the stream may legitimately be absent
- Fix the component responsible for creating the third stream
- Group sources into an array and use the array overload plus a filter for nulls before combining
Example fix
// before var combined = first.CombineLatest(second, third, ...); // third == null // after var combined = first.CombineLatest(second, third ?? Observable.Empty<TThird>(), ...);
Defensive patterns
Strategy: validation
Validate before calling
if (third == null) throw new InvalidOperationException("third stream must be initialized before CombineLatest"); Type guard
bool IsNonNull<T>(IObservable<T> s) => s is not null;
Try / catch
try { var combined = first.CombineLatest(second, third, /* ... */); } catch (ArgumentNullException ex) when (ex.ParamName == "third") { /* fix or default the third stream */ } Prevention
- Guard every stream-producing service against null returns at its boundary
- Rename stale fields after refactors so leftover nulls are visible
- Build source lists in a collection and validate before combining
- Adopt nullable reference types to surface uninitialized streams early
When it happens
Trigger: Passing null as the third IObservable<TThird> to the 9-argument CombineLatest overload.
Common situations: Combining three-plus sensor or UI streams where one service dependency was null; unit-test scaffolding that left a stub stream uninitialized; refactors that renamed a local but left a stale null field in place.
Related errors
- keySelector
- Value cannot be null. (Parameter 'keySelector')
- Value cannot be null. (Parameter 'comparer')
- Value cannot be null. (Parameter 'first')
- Value cannot be null. (Parameter 'second')
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/4bf19c4649f38860.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs:1447
/// <param name="first">First observable source.</param>
/// <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>
/// <param name="sixth">Sixth observable source.</param>
/// <param name="seventh">Seventh observable source.</param>
/// <param name="eighth">Eighth observable source.</param>
/// <param name="ninth">Ninth 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"/> or <paramref name="eighth"/> or <paramref name="ninth"/> is null.</exception>
public static IObservable<(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>(this IObservable<TFirst> first, IObservable<TSecond> second, IObservable<TThird> third, IObservable<TFourth> fourth, IObservable<TFifth> fifth, IObservable<TSixth> sixth, IObservable<TSeventh> seventh, IObservable<TEighth> eighth, IObservable<TNinth> ninth)
{
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 s_impl.CombineLatest(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth);
}
/// <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)