dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'third')
Error message
Value cannot be null. (Parameter 'third')
What it means
ArgumentNullException with message "Value cannot be null. (Parameter 'third')" is thrown by the 10-source CombineLatest overload when the third source sequence is null. The method validates each of the ten source arguments before constructing the query expression, since a null argument cannot be embedded in the Expression.Call tree sent to the IQbservableProvider.
Solutions
- Pass a non-null IObservable<TThird>; if the stream is legitimately absent, use Observable.Empty<TThird>() or a Never sequence.
- Fix the producer of the third stream so it never returns null (throw or return Empty instead).
- Drop the third argument and use a 9-argument CombineLatest overload if the source is truly optional.
Example fix
// before var combined = first.CombineLatest(second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth); // after var combined = first.CombineLatest(second, third ?? Observable.Empty<TThird>(), fourth, fifth, sixth, seventh, eighth, ninth, tenth);
Defensive patterns
Strategy: validation
Validate before calling
if (third is null) throw new InvalidOperationException("third source must be a non-null IObservable<TThird>");
// or: third ??= Observable.Empty<TThird>(); Type guard
static bool IsValidSource<T>(IObservable<T>? source) => source is not null;
Try / catch
try
{
var combined = first.CombineLatest(second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth);
}
catch (ArgumentNullException ex) when (ex.ParamName == "third")
{
// handle missing third source
} Prevention
- Replace null-returning stream factories with ones that return Observable.Empty or Observable.Throw.
- Coalesce optional sources with ?? Observable.Empty<T>().
- Prefer lower-arity CombineLatest overloads when a source is genuinely optional.
When it happens
Trigger: Calling QbservableEx.CombineLatest(first, second, third, ..., tenth) with third == null; the guard at QbservableEx.Homoicon.cs:411-412 fires after first and second pass validation.
Common situations: Merging sensor/event streams where one stream factory returned null; nullable IObservable fields from incomplete initialization; calling code paths where an optional third stream is passed as null instead of Observable.Empty.
Related errors
- Value cannot be null. (Parameter 'fourth')
- Value cannot be null. (Parameter 'fifth')
- Value cannot be null. (Parameter 'sixth')
- Value cannot be null. (Parameter 'seventh')
- Value cannot be null. (Parameter 'eighth')
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/d996fc6c8600a255.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.Homoicon.cs:411
/// <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>
/// <param name="tenth">Tenth 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" /> or <paramref name="tenth" /> is null.</exception>
public static IQbservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth, TTenth Tenth)> CombineLatest<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth, TTenth>(this IQbservable<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, IObservable<TTenth> tenth)
{
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));
if (tenth == null)
throw new ArgumentNullException(nameof(tenth));
return first.Provider.CreateQuery<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth, TTenth Tenth)>(
Expression.Call(
null,View on GitHub (pinned to 94b5d5ab91)