dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'twelfth')
Error message
Value cannot be null. (Parameter 'twelfth')
What it means
This ArgumentNullException is thrown by the 12-source Qbservable.CombineLatest overload when the twelfth (last) source sequence is null. Like all Qbservable operators, CombineLatest eagerly null-checks every source before constructing the Expression.Call that describes the query, so a null twelfth argument fails immediately at call time. The parameter name in the exception points at the offending argument.
Solutions
- Ensure the twelfth argument is a non-null IObservable<TTwelfth> before the call.
- Coalesce to a default sequence such as Observable.Empty<TTwelfth>() when the source is optional.
- Fix the producer of the twelfth sequence so it never returns null.
Example fix
// before var query = first.CombineLatest(s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12); // after var query = first.CombineLatest(s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12 ?? Observable.Empty<TTwelfth>());
Defensive patterns
Strategy: validation
Validate before calling
if (s12 == null) throw new InvalidOperationException("twelfth CombineLatest source is null"); // or s12 = s12 ?? Observable.Empty<TTwelfth>(); Type guard
bool IsValidSource<T>(IObservable<T> s) => s is not null;
Try / catch
try { var query = first.CombineLatest(..., s12); } catch (ArgumentNullException ex) when (ex.ParamName == "twelfth") { /* substitute default source */ } Prevention
- Check the last arguments of wide CombineLatest calls after signature changes
- Build sources via factory methods that throw meaningful errors instead of returning null
- Enable C# nullable reference type analysis
When it happens
Trigger: Calling the 12-argument CombineLatest extension (Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.Homoicon.cs:572) with null for the twelfth IObservable<TTwelfth> argument.
Common situations: The last source in a long CombineLatest chain is frequently the one forgotten after a signature change or when it comes from an optional service/config that resolved to null.
Related errors
- Value cannot be null. (Parameter 'eleventh')
- ArgumentNullException(nameof(second))
- ArgumentNullException(nameof(sources))
- Value cannot be null. (Parameter 'onNextAsync')
- Value cannot be null. (Parameter 'onErrorAsync')
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/98717586c7bd8822.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.Homoicon.cs:572
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));
return first.Provider.CreateQuery<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth, TTenth Tenth, TEleventh Eleventh, TTwelfth Twelfth)>(
Expression.Call(
null,
new Func<IQbservable<TFirst>, IObservable<TSecond>, IObservable<TThird>, IObservable<TFourth>, IObservable<TFifth>, IObservable<TSixth>, IObservable<TSeventh>, IObservable<TEighth>, IObservable<TNinth>, IObservable<TTenth>, IObservable<TEleventh>, IObservable<TTwelfth>, IQbservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth, TTenth Tenth, TEleventh Eleventh, TTwelfth Twelfth)>>(CombineLatest<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth, TTenth, TEleventh, TTwelfth>).Method,
first.Expression,
GetSourceExpression(second),
GetSourceExpression(third),
GetSourceExpression(fourth),
GetSourceExpression(fifth),
GetSourceExpression(sixth),
GetSourceExpression(seventh),
GetSourceExpression(eighth),
GetSourceExpression(ninth),
GetSourceExpression(tenth),
GetSourceExpression(eleventh),
GetSourceExpression(twelfth)
)View on GitHub (pinned to 94b5d5ab91)