{"record":{"id":"2eee1b0ab4f78450","repo":"dotnet/reactive","slug":"strings-core-completed-no-value","errorCode":null,"errorMessage":"Strings_Core.COMPLETED_NO_VALUE","messagePattern":"Strings_Core\\.COMPLETED_NO_VALUE","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Notification.cs","lineNumber":403,"sourceCode":"        internal sealed class OnCompletedNotification : Notification<T>\n        {\n            /// <summary>\n            /// Complete notifications are stateless thus only one instance\n            /// can ever exist per type.\n            /// </summary>\n            internal static readonly Notification<T> Instance = new OnCompletedNotification();\n\n            /// <summary>\n            /// Constructs a notification of the end of a sequence.\n            /// </summary>\n            private OnCompletedNotification()\n            {\n            }\n\n            /// <summary>\n            /// Throws an <see cref=\"InvalidOperationException\"/>.\n            /// </summary>\n            public override T Value { get { throw new InvalidOperationException(Strings_Core.COMPLETED_NO_VALUE); } }\n\n            /// <summary>\n            /// Returns <c>null</c>.\n            /// </summary>\n            public override Exception? Exception => null;\n\n            /// <summary>\n            /// Returns <c>false</c>.\n            /// </summary>\n            public override bool HasValue => false;\n\n            /// <summary>\n            /// Returns <see cref=\"NotificationKind.OnCompleted\"/>.\n            /// </summary>\n            public override NotificationKind Kind => NotificationKind.OnCompleted;\n\n            /// <summary>\n            /// Returns the hash code for this instance.","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Notification.cs#L385-L421","documentation":"OnCompletedNotification<T>.Value throws InvalidOperationException with Strings_Core.COMPLETED_NO_VALUE. An OnCompleted notification carries no value, so reading .Value is semantically invalid; Rx models this as an InvalidOperationException rather than returning default(T) to avoid silently propagating a meaningless value.","triggerScenarios":"Accessing the Value property of a Notification<T> whose Kind is OnCompleted — typically without first checking notification.Kind or pattern-matching on the concrete notification type.","commonSituations":"Code that receives materialized notifications from a sequence, logs or serializes all notifications uniformly, and reads Value unconditionally; or unit-test assertions that inspect Value for every notification.","solutions":["Check notification.Kind == NotificationKind.OnCompleted (or OnError) before reading Value.","Pattern-match on the concrete type (OnNextNotification<T> vs OnCompletedNotification<T> / OnErrorNotification<T>).","Use Accept with handlers instead of touching Value directly."],"exampleFix":"// before\nvar value = notification.Value;\n// after\nvar value = notification.Kind == NotificationKind.OnNext ? notification.Value : default;","handlingStrategy":"type-guard","validationCode":"if (notification.Kind != NotificationKind.OnNext) throw new InvalidOperationException(\"Value is only available on OnNext notifications\");\nvar value = notification.Value;","typeGuard":"static bool TryGetValue<T>(Notification<T> n, out T? value) { value = default; return n.Kind == NotificationKind.OnNext && (value = n.Value) is not null || n.Kind == NotificationKind.OnNext; } // safer: pattern-match concrete types","tryCatchPattern":"try { value = notification.Value; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"COMPLETED\") || ex.Message.Contains(\"completed\")) { value = default; }","preventionTips":["Always check notification.Kind before touching Value.","Prefer pattern matching on OnNextNotification<T> / OnErrorNotification<T> / OnCompletedNotification<T>.","Prefer Accept with handlers so value/completion branching is enforced by the API."],"tags":["invalid-operation","rx-notification","no-value"],"backgroundTag":"unsupported-operation","analyzedSha":"94b5d5ab912789f5abe9a72138a25bbd716fe59c","analyzedAt":"2026-09-15T02:26:24.759Z","contentChangedAt":"2026-09-15T02:26:24.759Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}