dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'fifth')
Error message
Value cannot be null. (Parameter 'fifth')
What it means
The five-source Zip overload validates all arguments and throws ArgumentNullException when the 'fifth' observable sequence is null. Rx fails fast at composition time so the bad call is caught immediately rather than during subscription. The fifth source was null at the call site.
Solutions
- Replace the null fifth argument with Observable.Empty<TFifth>() or a real source
- Guard the call: if (fifth == null) handle/throw with context before composing
- Fix the factory producing the fifth stream to never return null
Example fix
// before var zipped = Observable.Zip(a, b, c, d, e); // e == null // after var zipped = Observable.Zip(a, b, c, d, e ?? Observable.Empty<TFifth>());
Defensive patterns
Strategy: validation
Validate before calling
var sources = new[] { first, second, third, fourth, fifth };
if (sources.Any(s => s == null)) throw new ArgumentNullException(nameof(fifth), "All Zip sources must be non-null"); Type guard
bool Ready(IObservable<object>? s) => s is not null;
Try / catch
try { var zipped = Observable.Zip(a, b, c, d, e); }
catch (ArgumentNullException ex) when (ex.ParamName == "fifth") { /* default the fifth source or abort composition */ } Prevention
- Substitute Observable.Empty for disabled/optional streams instead of null
- Guard optional source producers with contracts (Debug.Assert / ThrowIfNull)
- Review nullable warnings rather than suppressing them
When it happens
Trigger: Calling Observable.Zip(first, second, third, fourth, fifth) with fifth == null, e.g. the last source came from an optional API whose null result was forwarded directly.
Common situations: Optional last-stage streams (telemetry, audit) that return null when disabled, migration from older code where null meant 'no source', or misordered arguments shifting nulls into the fifth slot.
Related errors
- Value cannot be null. (Parameter 'source9')
- nameof(onError)
- nameof(onCompleted)
- nameof(witness)
- Value cannot be null. (Parameter 'source9')
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/a08066b0835da8d8.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs:1281
/// <param name="first">First observable source.</param>
/// <param name="second">Second observable source.</param>
/// <param name="third">Third observable source.</param>
/// <param name="fourth">Fourth observable source.</param>
/// <param name="fifth">Fifth observable source.</param>
/// <returns>An observable sequence containing the result of combining elements of the sources using tuple values.</returns>
/// <exception cref="ArgumentNullException"><paramref name="first"/> or <paramref name="second"/> or <paramref name="third"/> or <paramref name="fourth"/> or <paramref name="fifth"/> is null.</exception>
public static IObservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth)> Zip<TFirst, TSecond, TThird, TFourth, TFifth>(this IObservable<TFirst> first, IObservable<TSecond> second, IObservable<TThird> third, IObservable<TFourth> fourth, IObservable<TFifth> fifth)
{
if (first == null)
throw new ArgumentNullException(nameof(first));
if (second == null)
throw new ArgumentNullException(nameof(second));
if (third == null)
throw new ArgumentNullException(nameof(third));
if (fourth == null)
throw new ArgumentNullException(nameof(fourth));
if (fifth == null)
throw new ArgumentNullException(nameof(fifth));
return s_impl.Zip(first, second, third, fourth, fifth);
}
/// <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>
/// <typeparam name="TSixth">The type of the elements in the sixth source sequence.</typeparam>
/// <param name="first">First observable source.</param>
/// <param name="second">Second observable source.</param>
/// <param name="third">Third observable source.</param>
/// <param name="fourth">Fourth observable source.</param>
/// <param name="fifth">Fifth observable source.</param>View on GitHub (pinned to 94b5d5ab91)