{"record":{"id":"fc69271ff7cac365","repo":"phalcon/cphalcon","slug":"macro-name-was-called-without-parameter-vari","errorCode":null,"errorMessage":"Macro '{name}' was called without parameter: {variableName}","messagePattern":"Macro '(.+?)' was called without parameter: (.+?)","errorType":"exception","errorClass":"Phalcon\\Mvc\\View\\Exception","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/View/Engine/Volt/Compiler.zep","lineNumber":1110,"sourceCode":"            /**\n             * Parameters are always received as an array\n             */\n            let code .= macroName . \" = function($__p = null) { \";\n\n            for position, parameter in parameters {\n                let variableName = parameter[\"variable\"];\n\n                let code .= \"if (isset($__p[\" . position . \"])) { \";\n                let code .= \"$\" . variableName . \" = $__p[\" . position .\"];\";\n                let code .= \" } else { \";\n                let code .= \"if (array_key_exists(\\\"\" . variableName . \"\\\", $__p)) { \";\n                let code .= \"$\" . variableName . \" = $__p[\\\"\" . variableName .\"\\\"];\";\n                let code .= \" } else { \";\n\n                if likely fetch defaultValue, parameter[\"default\"] {\n                    let code .= \"$\" . variableName . \" = \" . this->expression(defaultValue) . \";\";\n                } else {\n                    let code .= \" throw new \\\\Phalcon\\\\Mvc\\\\View\\\\Exception(\\\"Macro '\" . name . \"' was called without parameter: \" . variableName . \"\\\"); \";\n                }\n\n                let code .= \" } } \";\n            }\n\n            let code .= \" ?>\";\n        }\n\n        /**\n         * Block statements are allowed\n         */\n        if fetch blockStatements, statement[\"block_statements\"] {\n            /**\n             * Process statements block\n             */\n            let code .= this->statementList(blockStatements, extendsMode) . \"<?php }; \";\n        }  else {\n            let code .= \"<?php }; \";","sourceCodeStart":1092,"sourceCodeEnd":1128,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/View/Engine/Volt/Compiler.zep#L1092-L1128","documentation":"When the Volt compiler (compileMacro) compiles a macro parameter that has no default value, it emits a `throw new \\Phalcon\\Mvc\\View\\Exception(\"Macro '<name>' was called without parameter: <var>\")` directly into the compiled template code (phalcon/Mvc/View/Engine/Volt/Compiler.zep:1110). The error therefore fires at render time, not compile time: calling the macro without that argument (positionally or by name) executes the throw.","triggerScenarios":"{% macro avatar(url, alt) %}...{% endmacro %} then {{ avatar('/img/a.png') }} — 'alt' has no default and is not supplied. Misspelled named arguments also fall through to this branch (array_key_exists on the exact name fails).","commonSituations":"Adding a new required parameter to a shared macro while some callers are not updated; templates calling macros with named args that got renamed; removing a default during refactor; errors only appear on pages that actually invoke the macro.","solutions":["Pass every required argument: {{ avatar('/img/a.png', 'Profile') }} or named: {{ avatar(url='/img/a.png', alt='Profile') }}.","Give the parameter a default in the definition so old callers keep working: {% macro avatar(url, alt='Image') %}.","As a safety net, catch Phalcon\\Mvc\\View\\Exception around view rendering to render a friendly error page while you fix callers."],"exampleFix":"{# before #}\n{% macro avatar(url, alt) %}<img src=\"{{ url }}\" alt=\"{{ alt }}\">{% endmacro %}\n{{ avatar('/img/a.png') }}\n\n{# after #}\n{% macro avatar(url, alt='Image') %}<img src=\"{{ url }}\" alt=\"{{ alt }}\">{% endmacro %}\n{{ avatar('/img/a.png') }}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $view->render('profile', $params);\n} catch (\\Phalcon\\Mvc\\View\\Exception $e) {\n    if (str_contains($e->getMessage(), 'was called without parameter')) {\n        $logger->error('Volt macro call missing argument: ' . $e->getMessage());\n    }\n    throw $e;\n}","preventionTips":["Give every macro parameter a default unless absence is truly exceptional.","Search the codebase for macro invocations when adding a parameter to a shared macro.","Remember the failure happens at render time — smoke-render the pages that use each macro in tests."],"tags":["phalcon","volt","template","macro","view","argument-missing"],"backgroundTag":"template-macro-missing-argument","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}