dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'twelfth')
Error message
Value cannot be null. (Parameter 'twelfth')
What it means
In the 12-source CombineLatest overload, System.Reactive throws ArgumentNullException when the twelfth (last) observable sequence is null. All arguments are null-checked before s_impl.CombineLatest is invoked, so the throw is synchronous and occurs before any subscription. The parameter name in the message identifies the null argument.
Solutions
- Provide a valid IObservable<T> as the twelfth argument; fall back to Observable.Empty<T>() if it is intentionally absent.
- Check the assignment/lookup that produces the twelfth sequence and fix the null path.
- Migrate to the collection overload CombineLatest(sources, resultSelector) and validate the list length/nulls once.
- Apply a null-coalescing default at the call site.
Example fix
// before var combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, null); // twelfth null // after var twelfth = GetTwelfth() ?? Observable.Empty<int>(); var combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, twelfth);
Defensive patterns
Strategy: validation
Validate before calling
if (twelfth is null) throw new InvalidOperationException("twelfth source must be provided");
twelfth ??= Observable.Empty<TTwelfth>(); Type guard
static bool IsNotNull<T>(IObservable<T>? s) => s is not null;
Try / catch
try
{
var combined = Observable.CombineLatest(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12);
}
catch (ArgumentNullException ex) when (ex.ParamName == "twelfth")
{
logger.LogWarning("twelfth source was null");
throw;
} Prevention
- Verify argument count after copy-pasting long CombineLatest calls
- Use named arguments (twelfth:) to make dropped arguments visible
- Never let optional streams default to null; default to Observable.Empty<T>()
- Prefer collection-based overloads when arity grows past a handful of sources
When it happens
Trigger: Calling Observable.CombineLatest(first..twelfth) with null as the twelfth (Twelfth) IObservable<T> argument, e.g. omitting the last source when copying an example or passing a nullable stream variable that was never assigned.
Common situations: Copy-paste edits of long argument lists dropping the final argument; optional last stream (e.g. telemetry) that is null in some environments; deserialized configuration where the 12th stream binding is missing.
Related errors
- Value cannot be null. (Parameter 'source6')
- Value cannot be null. (Parameter 'source7')
- Value cannot be null. (Parameter 'source13')
- Value cannot be null. (Parameter 'source15')
- Value cannot be null. (Parameter 'sixteenth')
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/b2bb6a5ee7716057.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs:1624
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 s_impl.CombineLatest(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth);
}
/// <summary>
/// Merges the specified observable sequences into one observable sequence of tuple values whenever any of the observable sequences produces an element.
/// </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>
/// <typeparam name="TSixth">The type of the elements in the sixth source sequence.</typeparam>
/// <typeparam name="TSeventh">The type of the elements in the seventh source sequence.</typeparam>
/// <typeparam name="TEighth">The type of the elements in the eighth source sequence.</typeparam>
/// <typeparam name="TNinth">The type of the elements in the ninth source sequence.</typeparam>
/// <typeparam name="TTenth">The type of the elements in the tenth source sequence.</typeparam>
/// <typeparam name="TEleventh">The type of the elements in the eleventh source sequence.</typeparam>View on GitHub (pinned to 94b5d5ab91)