dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'source13')
Error message
Value cannot be null. (Parameter 'source13')
What it means
The 13-source Observable.CombineLatest overload null-checks all 13 sources and then the resultSelector; this error means the thirteenth source (source13) was null. The last source is validated before the selector so the null-check order matches parameter order.
Solutions
- Ensure the thirteenth argument is a non-null IObservable<TSource13> before the call.
- Substitute Observable.Empty<TSource13>() if the final signal is optional (CombineLatest then completes when others finish).
- Hold Subjects/streams in non-null fields initialized at construction instead of null-then-assign.
Example fix
// before Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, trigger, sel); // trigger null // after var s13 = trigger ?? Observable.Empty<T13>(); Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, sel);
Defensive patterns
Strategy: validation
Validate before calling
if (source13 == null) throw new InvalidOperationException("source13 must be assigned before CombineLatest"); Type guard
bool IsValidSource13<T13>(IObservable<T13> s) => s is not null;
Try / catch
try { combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, sel); }
catch (ArgumentNullException ex) when (ex.ParamName == "source13") { log.LogError("source13 was null"); combined = Observable.Empty<TResult>(); } Prevention
- Assign trigger/completion streams before combining
- Never set Subjects to null after disposal; use a completed Subject instead
- Copy-paste long calls carefully and verify every positional argument
When it happens
Trigger: Calling Observable.CombineLatest with 13 sources where the final source argument is null, triggering the guard at Observable.Multiple.CombineLatest.cs:814.
Common situations: The last stream (often a completion/trigger signal) never assigned; copy-paste of the call missing the final source; a nullable subject that was disposed and set to null.
Related errors
- Value cannot be null. (Parameter 'source6')
- Value cannot be null. (Parameter 'source7')
- 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/6611b52ec518d90a.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs:814
if (source10 == null)
{
throw new ArgumentNullException(nameof(source10));
}
if (source11 == null)
{
throw new ArgumentNullException(nameof(source11));
}
if (source12 == null)
{
throw new ArgumentNullException(nameof(source12));
}
if (source13 == null)
{
throw new ArgumentNullException(nameof(source13));
}
if (resultSelector == null)
{
throw new ArgumentNullException(nameof(resultSelector));
}
return s_impl.CombineLatest(source1, source2, source3, source4, source5, source6, source7, source8, source9, source10, source11, source12, source13, 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)