{"record":{"id":"df9cb3af47487985","repo":"elsa-workflows/elsa-core","slug":"inputname-is-required","errorCode":null,"errorMessage":"{inputName} is required.","messagePattern":"(.+?) is required\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Workflows.Core/Extensions/InputExtensions.cs","lineNumber":45,"sourceCode":"        /// <summary>\n        /// Returns the value of the specified input, or a default value if the input is not found.\n        /// </summary>\n        public T? GetOrDefault(ExpressionExecutionContext context, Func<T>? defaultValue = default)\n        {\n            var value = context.Get(input);\n            return value != null ? value : defaultValue != null ? defaultValue.Invoke() : default;\n        }\n\n        /// <summary>\n        /// Returns the value of the specified input.\n        /// </summary>\n        /// <param name=\"context\">The context.</param>\n        /// <param name=\"inputName\">The name of the input.</param>\n        /// <returns>The value of the specified input.</returns>\n        /// <exception cref=\"Exception\">Throws an exception if the input is not found.</exception>\n        public T Get(ActivityExecutionContext context, [CallerArgumentExpression(\"input\")] string? inputName = default)\n        {\n            return context.Get(input) ?? throw new Exception($\"{inputName} is required.\");\n        }\n\n        /// <summary>\n        /// Returns the value of the specified input.\n        /// </summary>\n        /// <param name=\"context\">The context.</param>\n        /// <param name=\"inputName\">The name of the input.</param>\n        /// <returns>The value of the specified input.</returns>\n        /// <exception cref=\"Exception\">Throws an exception if the input is not found.</exception>\n        public T Get(ExpressionExecutionContext context, [CallerArgumentExpression(\"input\")] string? inputName = default)\n        {\n            return context.Get(input) ?? throw new Exception($\"{inputName} is required.\");\n        }\n    }\n}","sourceCodeStart":27,"sourceCodeEnd":60,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Workflows.Core/Extensions/InputExtensions.cs#L27-L60","documentation":"Thrown by Input<T>.Get when the resolved input value is null. It converts an implicit null dereference into an explicit error naming the input, enforcing that required inputs were actually supplied to the activity.","triggerScenarios":"Calling input.Get(context) (or accessing a required Input<T> property) when no value was set - the workflow was started without providing this input, the expression evaluating it returned null, or the input was never assigned in the designer.","commonSituations":"HTTP/workflow starters omitting a required workflow input key; expression inputs referencing missing variables; callers using nullable workflow input dictionaries that skip absent keys; default values removed from the activity definition.","solutions":["Supply the required input when starting/triggering the workflow (match the input name exactly).","Provide a default value on the Input<T> declaration or in the activity definition.","Make the input optional and null-check before use if absence is legitimate.","Validate required workflow inputs at workflow start (e.g., input validation endpoint) to fail early."],"exampleFix":"// before\npublic Input<string> OrderId { get; set; } = default!;\n// started without OrderId -> \"OrderId is required.\"\n\n// after\npublic Input<string?> OrderId { get; set; } = default!;\n// and guard:\nvar orderId = OrderId.Get(context);\nif (string.IsNullOrEmpty(orderId)) orderId = \"default-order\";","handlingStrategy":"try-catch","validationCode":"// before starting the workflow\nforeach (var required in new[] { \"OrderId\" })\n    if (!workflowInputs.ContainsKey(required))\n        throw new ArgumentException($\"Missing required workflow input '{required}'.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var orderId = OrderId.Get(context);\n}\ncatch (Exception ex) when (ex.Message == $\"{nameof(OrderId)} is required.\")\n{\n    // handle missing input: use default, compensate, or fail with guidance\n}","preventionTips":["Always pass required inputs at workflow start with exact names.","Set defaults on Input declarations when a value can be assumed.","Validate workflow inputs up front (start-time validation) instead of mid-execution.","Use nullable Input<T?> and explicit checks when inputs are optional."],"tags":["workflow","input","null-validation","csharp"],"backgroundTag":"missing-required-argument","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}