{"record":{"id":"48f7242d56cf9389","repo":"phalcon/cphalcon","slug":"macro-name-does-not-exist","errorCode":null,"errorMessage":"Macro '{name}' does not exist","messagePattern":"Macro '(.+?)' does not exist","errorType":"exception","errorClass":"Phalcon\\Mvc\\View\\Engine\\Volt\\Exceptions\\MacroNotFound","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/View/Engine/Volt.zep","lineNumber":65,"sourceCode":"    /**\n     * @var array\n     */\n    protected options = [];\n\n    /**\n     * Checks if a macro is defined and calls it\n     *\n     * @params string name\n     * @params array arguments\n     *\n     * @return mixed\n     */\n    public function callMacro( string name, array arguments = []) -> var\n    {\n        var macro;\n\n        if unlikely !fetch macro, this->macros[name] {\n            throw new MacroNotFound(name);\n        }\n\n        return call_user_func(macro, arguments);\n    }\n\n    /**\n     * Performs a string conversion\n     *\n     * @return string\n     */\n    public function convertEncoding(string text,  string from,  string to) -> string\n    {\n        if unlikely !this->phpFunctionExists(\"mb_convert_encoding\") {\n            throw new MbstringRequired();\n        }\n\n        return mb_convert_encoding(text, to, from);\n    }","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/View/Engine/Volt.zep#L47-L83","documentation":"Volt compiles calls to unknown template functions/macros into $this->callMacro($name, $args) on the Volt engine; if the name is not present in the registered macros map, MacroNotFound is thrown (phalcon/Mvc/View/Engine/Volt.zep:65). Macros come from { % macro name() % } definitions compiled from the current (or imported) template, so this error means the macro name was never defined or registered at call time.","triggerScenarios":"Template calls {{ formattedPrice(p) }} but the {% macro formattedPrice %} block is absent or lives in a template that was never imported; a typo between definition and call; macro defined after its use point; stale compiled template referencing a macro removed from the source.","commonSituations":"Refactoring shared macros into a separate macros.volt and forgetting {{ import('macros.volt') }} or the import alias; compileAlways/stale compiledVolt cache keeping an old macro set; copy-pasting template snippets between projects that rely on project-local macros.","solutions":["Define the macro in the same template above its first use, or import it: {% import 'macros.volt' as m %} then {{ m.formattedPrice(p) }}","Check for typos between macro definition name and call site","Clear the compiled Volt cache directory after moving/renaming macros"],"exampleFix":"// before (template.volt)\n{{ formattedPrice(product.price) }} {# macro never defined/imported #}\n\n// after\n{% import 'macros.volt' as m %}\n{{ m.formattedPrice(product.price) }}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"use Phalcon\\Mvc\\View\\Engine\\Volt\\Exceptions\\MacroNotFound;\ntry {\n    // template rendering that calls a possibly-missing macro\n    $html = $view->render('index/index');\n} catch (MacroNotFound $e) {\n    $logger->warning('Missing Volt macro: ' . $e->getMessage());\n    $html = $view->render('index/fallback');\n}","preventionTips":["Import macro libraries explicitly: {% import 'macros.volt' as m %}","Keep macro names in one shared template and import it in layouts","Clear the Volt compiled cache after macro renames","Prefer plain helpers/functions for logic shared across templates"],"tags":["phalcon","volt","macros","templates","cache"],"backgroundTag":"undefined-function","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}