{"record":{"id":"4e3e1b1670fd4f21","repo":"OrchardCMS/OrchardCore","slug":"missing-parameter-node-name","errorCode":null,"errorMessage":"Missing parameter: {node.Name}","messagePattern":"Missing parameter: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Queries/Sql/SqlParser.cs","lineNumber":260,"sourceCode":"                parts.AddRange(GetTableNameParts(tablePrefix + qualifier.Value));\n            }\n\n            for (var i = 1; i < node.Parts.Count; i++)\n            {\n                parts.Add(Quote(node.Parts[i].Value));\n            }\n\n            return node with { Parts = parts };\n        }\n\n        protected override SqlNode VisitParameter(ParameterExpression node)\n        {\n            if (parameters is not null && !parameters.ContainsKey(node.Name))\n            {\n                parameters[node.Name] = node.DefaultValue switch\n                {\n                    LiteralExpression { Value: bool or string or decimal or long } literal => literal.Value,\n                    null => throw new InvalidOperationException($\"Missing parameter: {node.Name}\"),\n                    _ => throw new InvalidOperationException(\"Unsupported default parameter value type\"),\n                };\n            }\n\n            return node;\n        }\n\n        protected override SqlNode VisitOrderByItem(OrderByItem node)\n        {\n            var rewritten = (OrderByItem)base.VisitOrderByItem(node);\n\n            return rewritten.Expression is FunctionCallExpression\n                {\n                    Name.Value: var name,\n                    Arguments.Count: 0,\n                } function\n                && name.Equals(\"random\", StringComparison.OrdinalIgnoreCase)\n                    ? rewritten with","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Queries/Sql/SqlParser.cs#L242-L278","documentation":"When the SQL query parser encounters a @Parameter with no default value and the caller's parameter dictionary does not contain that name, VisitParameter throws this error. SQL queries in Orchard Core require every referenced parameter to be supplied at execution time unless a default literal is declared.","triggerScenarios":"Executing a SQL query whose text references @SomeParam, with no default value in the query (no SET @SomeParam = ...) and 'SomeParam' absent from the parameters dictionary passed to the query manager.","commonSituations":"Calling the Queries API directly and forgetting to add a parameter; renaming a parameter in the SQL but not in the calling code; recipe/template code invoking a query that expects user-supplied parameters.","solutions":["Pass the missing key in the parameters dictionary when executing the query","Add a default value in the SQL query, e.g. SET @SomeParam = 'default', so the parser can supply it","Fix the parameter name mismatch between the query text and the caller's dictionary"],"exampleFix":"// before\nawait _queryManager.ExecuteQueryAsync(query); // query uses @Category but no default\n// after\nawait _queryManager.ExecuteQueryAsync(query, new Dictionary<string, object> { [\"Category\"] = \"news\" });","handlingStrategy":"validation","validationCode":"var missing = queryDoc.Parameters.Where(p => !parameters.ContainsKey(p) && p.DefaultValue is null).ToList();\nif (missing.Count > 0) throw new ArgumentException($\"Missing query parameters: {string.Join(\", \", missing)}\");","typeGuard":null,"tryCatchPattern":"try { await _queryManager.ExecuteQueryAsync(query, parameters); } catch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Missing parameter\")) { /* surface missing parameter name to caller */ }","preventionTips":["Enumerate the query's declared parameters and validate the dictionary before executing","Keep parameter names in the SQL text and calling code in sync (single source of constants)","Provide defaults in SQL for optional parameters"],"tags":["sql","queries","parameters"],"backgroundTag":"missing-required-argument","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}