dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'twelfth')
Error message
Value cannot be null. (Parameter 'twelfth')
What it means
System.Reactive's Zip implementation guards each of its many observable source parameters with ArgumentNullException. A null twelfth sequence hits the check at Observable.Multiple.Zip.cs:1805, throwing with Parameter 'twelfth'. The library throws eagerly so the invalid query fails at construction rather than at subscription time.
Solutions
- Provide a non-null IObservable<T> for the twelfth source; use Observable.Empty<TTwelfth>() when the source is intentionally absent.
- Validate or coalesce all source arguments before calling Zip.
- Fix the initialization/configuration that produced the null twelfth stream.
- Use the IEnumerable-based Zip overload when the source count varies.
- Catch ArgumentNullException at the composition site and log which positional source was missing.
Example fix
// before var merged = Zip15(s1, ..., s12, s13, s14, s15); // s12 == null // after var merged = Zip15(s1, ..., s12 ?? Observable.Empty<T12>(), s13, s14, s15);
Defensive patterns
Strategy: validation
Validate before calling
if (s12 is null) throw new InvalidOperationException("twelfth source not initialized"); Type guard
static bool IsReady(IObservable<T>? s) => s is not null;
Try / catch
try { merged = Zip15(s1, ..., s15); }
catch (ArgumentNullException ex) when (ex.ParamName == "twelfth") { merged = Observable.Empty<(T1,...,T15)>(); } Prevention
- Gate feature-flagged pipelines so disabled features contribute Observable.Empty.
- Initialize all stream variables before composing the query.
- Use a builder that validates sources instead of raw positional calls.
- Add Debug.Assert(source != null) checks in composition helpers.
When it happens
Trigger: Calling the public static Observable.Zip overload accepting up to fifteen IObservable<T> sources with null in the twelfth argument position, e.g. Observable.Zip(s1, ..., s11, null, s13, s14, s15).
Common situations: Optional streams in a feature-flagged pipeline left null when a feature is off; arrays of feeds iterated positionally with a missing element; migration from a different reactive library that tolerated null sources.
Related errors
- Value cannot be null. (Parameter 'thirteenth')
- Value cannot be null. (Parameter 'fourteenth')
- Value cannot be null. (Parameter 'fifteenth')
- Value cannot be null. (Parameter 'source10')
- Value cannot be null. (Parameter 'tenth')
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/0e8b9ce35d4606cf.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs:1805
throw new ArgumentNullException(nameof(third));
if (fourth == null)
throw new ArgumentNullException(nameof(fourth));
if (fifth == null)
throw new ArgumentNullException(nameof(fifth));
if (sixth == null)
throw new ArgumentNullException(nameof(sixth));
if (seventh == null)
throw new ArgumentNullException(nameof(seventh));
if (eighth == null)
throw new ArgumentNullException(nameof(eighth));
if (ninth == null)
throw new ArgumentNullException(nameof(ninth));
if (tenth == null)
throw new ArgumentNullException(nameof(tenth));
if (eleventh == null)
throw new ArgumentNullException(nameof(eleventh));
if (twelfth == null)
throw new ArgumentNullException(nameof(twelfth));
if (thirteenth == null)
throw new ArgumentNullException(nameof(thirteenth));
if (fourteenth == null)
throw new ArgumentNullException(nameof(fourteenth));
if (fifteenth == null)
throw new ArgumentNullException(nameof(fifteenth));
return s_impl.Zip(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth);
}
/// <summary>
/// Merges the specified observable sequences into one observable sequence of tuple values whenever all of the observable sequences have produced an element at a corresponding index.
/// </summary>
/// <typeparam name="TFirst">The type of the elements in the first source sequence.</typeparam>
/// <typeparam name="TSecond">The type of the elements in the second source sequence.</typeparam>
/// <typeparam name="TThird">The type of the elements in the third source sequence.</typeparam>
/// <typeparam name="TFourth">The type of the elements in the fourth source sequence.</typeparam>
/// <typeparam name="TFifth">The type of the elements in the fifth source sequence.</typeparam>View on GitHub (pinned to 94b5d5ab91)