{"record":{"id":"76d453670ef48b45","repo":"elsa-workflows/elsa-core","slug":"unexpected-non-optional-non-input-t-parameter-param-name-in","errorCode":null,"errorMessage":"Unexpected non-optional, non-Input<T> parameter '{param.Name}' in constructor for '{activityType.Name}'","messagePattern":"Unexpected non-optional, non-Input<T> parameter '(.+?)' in constructor for '(.+?)'","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Dsl.ElsaScript/Compiler/ElsaScriptCompiler.cs","lineNumber":591,"sourceCode":"            // Check if this is one of our Input<T> parameters\n            var inputParamIndex = Array.IndexOf(selectedInputParams, param);\n\n            if (inputParamIndex >= 0)\n            {\n                // This is an Input<T> parameter - compile the corresponding positional argument\n                var arg = positionalArgs[inputParamIndex];\n                var value = CompileExpression(arg.Value, param.ParameterType);\n                ctorArgs.Add(value);\n            }\n            else if (param.IsOptional)\n            {\n                // This is an optional parameter (like CallerFilePath) - use its default value\n                ctorArgs.Add(param.DefaultValue);\n            }\n            else\n            {\n                // This shouldn't happen if our filtering is correct\n                throw new InvalidOperationException(\n                    $\"Unexpected non-optional, non-Input<T> parameter '{param.Name}' in constructor for '{activityType.Name}'\");\n            }\n        }\n\n        // Instantiate the activity using the constructor\n        var activity = (IActivity)selectedCtor.Invoke(ctorArgs.ToArray());\n        return activity;\n    }\n\n    private static string MapLanguageName(string dslLanguage) =>\n        LanguageMappings.TryGetValue(dslLanguage, out var mapped) ? mapped : dslLanguage;\n}\n","sourceCodeStart":573,"sourceCodeEnd":604,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Dsl.ElsaScript/Compiler/ElsaScriptCompiler.cs#L573-L604","documentation":"After selecting a constructor, the compiler fills Input<T> parameters from arguments and skips optional parameters using their defaults. If it encounters a required (non-optional) parameter that is not Input<T>, it cannot supply a value and throws this InvalidOperationException. The message notes this 'shouldn't happen if filtering is correct', marking an unexpected activity constructor shape.","triggerScenarios":"An activity constructor mixes required non-Input parameters (e.g. a required string or service parameter without a default) alongside Input<T> parameters, and that constructor is selected during positional invocation.","commonSituations":"Custom activities written with plain required constructor parameters instead of Input<T>; third-party activities not designed for ElsaScript constructor instantiation.","solutions":["Rewrite the activity constructor so all required parameters are Input<T> types","Give non-Input parameters default values so they are treated as optional","Use named arguments targeting only Input<T> parameters, avoiding the offending constructor","Wrap or adapt the third-party activity with an Elsa-compatible constructor"],"exampleFix":"// before\npublic MyActivity(string name, Input<string> text) { ... }\n// after\npublic MyActivity(Input<string> name, Input<string> text) { ... }","handlingStrategy":"type-guard","validationCode":"bool HasOnlyInputOrOptionalParams(ConstructorInfo c) =>\n    c.GetParameters().All(p => IsInputType(p.ParameterType) || p.HasDefaultValue);","typeGuard":"static bool IsValidActivityConstructor(ConstructorInfo c) =>\n    c.GetParameters().All(p => typeof(IInput).IsAssignableFrom(p.ParameterType) || p.HasDefaultValue);","tryCatchPattern":null,"preventionTips":["Author activity constructors so required parameters are Input<T> and everything else has defaults","Never add raw required service/string parameters to activity constructors","Audit custom activities for non-Input required parameters before enabling ElsaScript authoring"],"tags":["elsascript","compiler","activity","constructor"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}