dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'source15')
Error message
Value cannot be null. (Parameter 'source15')
What it means
ArgumentNullException (Parameter 'source15'): the 15th source in the 16-ary Observable.Zip overload is null. Rx rejects null sources eagerly so the bug surfaces at the composition call site rather than as an obscure error inside the zip machinery after subscription.
Solutions
- Guarantee source15 is initialized before composing the zip (fix initialization order).
- Use Observable.Empty<T>() or Observable.Never<T>() for intentionally missing streams.
- Wrap composition in a helper that validates all 16 arguments and reports null indices.
- Prefer collection-based Zip to eliminate fixed-arity null gaps.
Example fix
// before Zip(..., s14, s15 /* null */, s16, ..., sel); // after Zip(..., s14, s15 ?? Observable.Empty<byte[]>(), s16, ..., sel);
Defensive patterns
Strategy: validation
Validate before calling
if (source15 == null) throw new ArgumentNullException(nameof(source15)); // or: var s15 = source15 ?? Observable.Empty<T15>();
Type guard
static bool Present<T>([NotNullWhen(true)] IObservable<T>? o) => o is not null; var s15 = Present(source15) ? source15 : Observable.Empty<T15>();
Try / catch
try
{
var zipped = Observable.Zip(source1, /* ... */ source15, /* ... */ source16, selector);
}
catch (ArgumentNullException ex) when (ex.ParamName == nameof(source15))
{
logger.LogError(ex, "source15 was null when composing Zip");
} Prevention
- Complete async initialization before composing dependent pipelines.
- Fail fast in constructors/factories when a required stream cannot be created.
- Keep stream construction close to composition to avoid stale null references.
- Enable nullable reference types and annotate producers as [NotNullWhen(true)].
When it happens
Trigger: Observable.Zip(source1..source16, resultSelector) with source15 == null — e.g. an async initializer that had not completed, a service locator returning null, or a refactoring that dropped one argument assignment.
Common situations: Startup ordering bugs where a stream is created after zip composition, mocked dependencies that default to null in tests, or partial application of a stream-builder result.
Related errors
- Value cannot be null. (Parameter 'source14')
- Value cannot be null. (Parameter 'source16')
- Value cannot be null. (Parameter 'first')
- Value cannot be null. (Parameter 'source1')
- Value cannot be null. (Parameter 'source2')
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/5b6f75baf31f6b0a.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs:1164
if (source12 == null)
{
throw new ArgumentNullException(nameof(source12));
}
if (source13 == null)
{
throw new ArgumentNullException(nameof(source13));
}
if (source14 == null)
{
throw new ArgumentNullException(nameof(source14));
}
if (source15 == null)
{
throw new ArgumentNullException(nameof(source15));
}
if (source16 == null)
{
throw new ArgumentNullException(nameof(source16));
}
if (resultSelector == null)
{
throw new ArgumentNullException(nameof(resultSelector));
}
return s_impl.Zip(source1, source2, source3, source4, source5, source6, source7, source8, source9, source10, source11, source12, source13, source14, source15, source16, resultSelector);
}
}
#pragma warning disable CA1711 // (Don't use Ex suffix.) This has been a public type for many years, so we can't rename it now.View on GitHub (pinned to 94b5d5ab91)