dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'source9')
Error message
Value cannot be null. (Parameter 'source9')
What it means
In the larger (11+ source) generated Zip overload, a null ninth sequence throws ArgumentNullException(Parameter 'source9'). All sources and the selector are validated eagerly before Create() builds the operator, so the error is thrown synchronously at the call site.
Solutions
- Null-check the ninth stream before the Zip call
- Replace null with AsyncObservable.Empty<T9>() when absence is valid
- Fix the upstream producer or collection initializer that yielded null
- Refactor to combine streams incrementally (pairwise Zip) so fewer arguments are positionally error-prone
Example fix
// before var zipped = AsyncObservable.Zip(s1..s8, GetNinth(), s10, s11, selector); // GetNinth() returned null // after var src9 = GetNinth() ?? AsyncObservable.Empty<T9>(); var zipped = AsyncObservable.Zip(s1..s8, src9, s10, s11, selector);
Defensive patterns
Strategy: validation
Validate before calling
if (source9 is null) source9 = AsyncObservable.Empty<T9>(); // or throw with context
Type guard
static bool IsValidSource<T>(IAsyncObservable<T>? s) => s is not null;
Try / catch
try
{
var zipped = AsyncObservable.Zip(s1, s2, s3, s4, s5, s6, s7, s8, source9, s10, s11, selector);
}
catch (ArgumentNullException ex) when (ex.ParamName == "source9")
{
// fall back to a 10-source composition without source9
} Prevention
- Null-coalesce optional streams at acquisition time, not at composition time
- Verify async factories returned non-null results before zipping
- Refactor very high-arity zips into staged pairwise combinations
- Add unit tests exercising every source slot in generated Zip calls
When it happens
Trigger: Calling the large-arity Zip overload where source9 (IAsyncObservable<T9>) is null.
Common situations: A null element in a programmatically built stream list; an optional ninth feed resolved to null; copy-paste of Zip call left one argument uninitialized.
Related errors
- Value cannot be null. (Parameter 'eighth')
- nameof(removeHandler)
- nameof(target)
- nameof(eventName)
- observer
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/4a8a3c8164ba2f6c.
Report an issue: GitHub.
Appendix: source
Thrown at AsyncRx.NET/System.Reactive.Async/Linq/Operators/Zip.Generated.cs:1036
{
if (source1 == null)
throw new ArgumentNullException(nameof(source1));
if (source2 == null)
throw new ArgumentNullException(nameof(source2));
if (source3 == null)
throw new ArgumentNullException(nameof(source3));
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 (source8 == null)
throw new ArgumentNullException(nameof(source8));
if (source9 == null)
throw new ArgumentNullException(nameof(source9));
if (source10 == null)
throw new ArgumentNullException(nameof(source10));
if (source11 == null)
throw new ArgumentNullException(nameof(source11));
if (selector == null)
throw new ArgumentNullException(nameof(selector));
return Create<TResult>(async observer =>
{
var d = new CompositeAsyncDisposable();
var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11) = AsyncObserver.Zip(observer, selector);
var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();View on GitHub (pinned to 94b5d5ab91)