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
- Assign a real IObservable<TSource9> to the ninth argument before the call.
- Use Observable.Empty<TSource9>() if the stream can legitimately be absent.
- Fix whatever producer returned null for that stream.
- 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 adding sources during refactors, update all call sites and guards together.
- Keep stream construction in a single validated method.
- Coalesce late-added sources with Observable.Empty.
- Enable nullable reference types.
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
- Value cannot be null. (Parameter 'onCompletedAsync')
- Value cannot be null. (Parameter 'onNext')
- Value cannot be null. (Parameter 'onError')
- Value cannot be null. (Parameter 'func')
- ArgumentNullException(nameof(onError))
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)