dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'source7')
Error message
Value cannot be null. (Parameter 'source7')
What it means
The 7-source CombineLatest overload (Observable.Multiple.CombineLatest.cs:265) throws ArgumentNullException when the seventh source observable is null. This is the last source checked before the resultSelector; CombineLatest subscribes to all seven streams and emits the latest combination whenever any stream produces a value, so every source must be non-null.
Solutions
- Ensure the seventh argument is a non-null IObservable<TSource7>.
- Default with source7 ?? Observable.Empty<TSource7>().
- Move query construction after the point where all streams are guaranteed initialized.
Example fix
// before var combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, timer ?? null, sel); // after var heartbeat = timer ?? Observable.Never<long>(); var combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, heartbeat, sel);
Defensive patterns
Strategy: validation
Validate before calling
if (source7 is null) source7 = Observable.Empty<T7>();
Type guard
static bool IsSourceValid<T>(IObservable<T>? s) => s is not null;
Try / catch
try { var combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, sel); }
catch (ArgumentNullException ex) when (ex.ParamName == "source7") { combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, Observable.Empty<T7>(), sel); } Prevention
- Initialize trailing streams (timers, signals) in constructors, not lazily.
- Delay query construction until all subjects/streams are created.
- Coalesce nullable fields at the call site: source7 ?? Observable.Empty<T7>().
- Review refactors that reduce stream count; update overloads, don't pass null.
When it happens
Trigger: Calling the 7-argument Observable.CombineLatest overload with a null seventh observable.
Common situations: The trailing stream (often a timer or shutdown signal) not created in some code paths; nullable readonly fields assigned in Initialize() that the query reads before initialization; conditional pipelines skipping the last stream.
Related errors
- Value cannot be null. (Parameter 'source6')
- Value cannot be null. (Parameter 'source13')
- Value cannot be null. (Parameter 'source15')
- Value cannot be null. (Parameter 'twelfth')
- Value cannot be null. (Parameter 'sixteenth')
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/c8954e488ed1fb93.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs:265
if (source4 == null)
{
throw new ArgumentNullException(nameof(source4));
}
if (source5 == null)
{
throw new ArgumentNullException(nameof(source5));
}
if (source6 == null)
{
throw new ArgumentNullException(nameof(source6));
}
if (source7 == null)
{
throw new ArgumentNullException(nameof(source7));
}
if (resultSelector == null)
{
throw new ArgumentNullException(nameof(resultSelector));
}
return s_impl.CombineLatest(source1, source2, source3, source4, source5, source6, source7, 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)