dotnet/reactive · error · ArgumentNullException
right
Error message
right
What it means
The Join operator throws ArgumentNullException because the required 'right' (second source) observable was null. This library validates all delegate and observable arguments up front so failures surface at call time rather than mid-subscription. Reactive pipelines composed with a null source cannot ever produce values, so it fails fast.
Solutions
- Pass a non-null IAsyncObservable<TRight> as the second argument to Join.
- If the right source may be absent, substitute an empty observable (e.g. AsyncObservable.Empty<TRight>()) instead of null.
- Check where the right observable is produced; fix the upstream factory/lookup so it never returns null.
Example fix
// before var result = left.Join(right!, l => l.Duration, r => r.Duration, (l, r) => (l, r)); // after if (right == null) right = AsyncObservable.Empty<TRight>(); var result = left.Join(right, l => l.Duration, r => r.Duration, (l, r) => (l, r));
Defensive patterns
Strategy: validation
Validate before calling
if (right is null) throw new ArgumentException("right source must be provided before joining", nameof(right)); Type guard
bool RightReady<TRight>(IAsyncObservable<TRight>? r) => r is not null;
Try / catch
try { var joined = left.Join(right, lds, rds, rs); }
catch (ArgumentNullException ex) when (ex.ParamName == "right") { /* substitute empty source or fail fast */ } Prevention
- Never return null from methods that produce observables; return AsyncObservable.Empty instead.
- Initialize all source fields before composing pipelines.
- Enable nullable reference types (C# 8+) so null sources are caught at compile time.
When it happens
Trigger: Calling left.Join(right, leftDurationSelector, rightDurationSelector, resultSelector) with right == null, e.g. a factory/config method returned null instead of an IAsyncObservable<TRight>.
Common situations: Building join sources conditionally (a missing optional stream yields null), wiring up sources from a dictionary/config lookup that misses a key, or refactoring where a source field was never initialized.
Related errors
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/a88e85cc1df1ff15.
Report an issue: GitHub.
Appendix: source
Thrown at AsyncRx.NET/System.Reactive.Async/Linq/Operators/Join.cs:19
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Reactive.Disposables;
using System.Threading;
using System.Threading.Tasks;
namespace System.Reactive.Linq
{
public partial class AsyncObservable
{
public static IAsyncObservable<TResult> Join<TLeft, TRight, TLeftDuration, TRightDuration, TResult>(this IAsyncObservable<TLeft> left, IAsyncObservable<TRight> right, Func<TLeft, IAsyncObservable<TLeftDuration>> leftDurationSelector, Func<TRight, IAsyncObservable<TRightDuration>> rightDurationSelector, Func<TLeft, TRight, TResult> resultSelector)
{
if (left == null)
throw new ArgumentNullException(nameof(left));
if (right == null)
throw new ArgumentNullException(nameof(right));
if (leftDurationSelector == null)
throw new ArgumentNullException(nameof(leftDurationSelector));
if (rightDurationSelector == null)
throw new ArgumentNullException(nameof(rightDurationSelector));
if (resultSelector == null)
throw new ArgumentNullException(nameof(resultSelector));
return CreateAsyncObservable<TResult>.From(
left,
(right, leftDurationSelector, rightDurationSelector, resultSelector),
static async (left, state, observer) =>
{
var subscriptions = new CompositeAsyncDisposable();
var (leftObserver, rightObserver, disposable) = AsyncObserver.Join(observer, subscriptions, state.leftDurationSelector, state.rightDurationSelector, state.resultSelector);
var leftSubscription = await left.SubscribeSafeAsync(leftObserver).ConfigureAwait(false);
await subscriptions.AddAsync(leftSubscription).ConfigureAwait(false);View on GitHub (pinned to 94b5d5ab91)