{"record":{"id":"22719fb9bd37ae37","repo":"MassTransit/MassTransit","slug":"value-cannot-be-null-parameter-values","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'values')","messagePattern":"Value cannot be null\\. \\(Parameter 'values'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/MassTransit/Clients/RequestClient.cs","lineNumber":38,"sourceCode":"            _timeout = timeout;\n        }\n\n        public RequestHandle<TRequest> Create(TRequest message, CancellationToken cancellationToken, RequestTimeout timeout)\n        {\n            async Task<TRequest> Request(Guid requestId, IPipe<SendContext<TRequest>> pipe, CancellationToken token)\n            {\n                await _requestSendEndpoint.Send(requestId, message, pipe, token).ConfigureAwait(false);\n\n                return message;\n            }\n\n            return new ClientRequestHandle<TRequest>(_context, Request, cancellationToken, timeout.Or(_timeout));\n        }\n\n        public RequestHandle<TRequest> Create(object values, CancellationToken cancellationToken = default, RequestTimeout timeout = default)\n        {\n            if (values == null)\n                throw new ArgumentNullException(nameof(values));\n\n            async Task<TRequest> Request(Guid requestId, IPipe<SendContext<TRequest>> pipe, CancellationToken token)\n            {\n                return await _requestSendEndpoint.Send(requestId, values, pipe, token).ConfigureAwait(false);\n            }\n\n            return new ClientRequestHandle<TRequest>(_context, Request, cancellationToken, timeout.Or(_timeout));\n        }\n\n        public Task<Response<T>> GetResponse<T>(TRequest message, CancellationToken cancellationToken, RequestTimeout timeout)\n            where T : class\n        {\n            return GetResponse<T>(message, null, cancellationToken, timeout);\n        }\n\n        public Task<Response<T>> GetResponse<T>(TRequest message, RequestPipeConfiguratorCallback<TRequest> callback,\n            CancellationToken cancellationToken = default, RequestTimeout timeout = default)\n            where T : class","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/MassTransit/MassTransit/blob/62ab339afa3bac2e9b3fe1769d0d35d7e44778e9/src/MassTransit/Clients/RequestClient.cs#L20-L56","documentation":"RequestClient.Create(object values) throws ArgumentNullException when the message values object used to initialize the request is null. The client needs a non-null message (or anonymous object) to build and send the request.","triggerScenarios":"Calling Create(null) on an IRequestClient<TRequest> — often when the message object is the result of a failed mapping or an uninitialized variable.","commonSituations":"Passing a deserialized message that came back null; building the request from optional data that was never populated.","solutions":["Ensure the message object is constructed before calling Create","Null-check/guard the message in the caller","Use the typed Create(TRequest message) overload with an initialized message instance"],"exampleFix":"// before\nvar handle = _client.Create(order ?? null);\n// after\nif (order == null) throw new InvalidOperationException(\"order required\");\nvar handle = _client.Create(order);","handlingStrategy":"validation","validationCode":"if (values is null) throw new InvalidOperationException(\"request message required\");","typeGuard":"bool HasMessage(object? v) => v is not null;","tryCatchPattern":"try { var h = client.Create(values); } catch (ArgumentNullException ex) { logger.LogError(ex, \"null request values\"); throw; }","preventionTips":["Null-check message objects before creating request handles","Prefer strongly-typed overloads with non-nullable reference types enabled","Fail fast when message construction produces null"],"tags":["null-check","request-response","argumentnull"],"backgroundTag":"null-argument","analyzedSha":"62ab339afa3bac2e9b3fe1769d0d35d7e44778e9","analyzedAt":"2026-09-13T22:47:47.593Z","contentChangedAt":"2026-09-13T22:47:47.593Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}