{"record":{"id":"777b0999400a684f","repo":"cakephp/cakephp","slug":"flash-message-missing","errorCode":null,"errorMessage":"Flash message missing.","messagePattern":"Flash message missing\\.","errorType":"http","errorClass":"InternalErrorException","httpStatus":500,"severity":"error","filePath":"src/Controller/Component/FlashComponent.php","lineNumber":171,"sourceCode":"     *\n     * Note that the parameter `element` will be always overridden. In order to call a\n     * specific element from a plugin, you should set the `plugin` option in $args.\n     *\n     * For example: `$this->Flash->warning('My message', ['plugin' => 'PluginName'])` would\n     * use the `warning.php` element under `plugins/PluginName/templates/element/flash/` for\n     * rendering the flash message.\n     *\n     * @param string $name Element name to use.\n     * @param array $args Parameters to pass when calling `FlashComponent::set()`.\n     * @return void\n     * @throws \\Cake\\Http\\Exception\\InternalErrorException If missing the flash message.\n     */\n    public function __call(string $name, array $args): void\n    {\n        $element = Inflector::underscore($name);\n\n        if (count($args) < 1) {\n            throw new InternalErrorException('Flash message missing.');\n        }\n\n        $options = ['element' => $element];\n\n        if (isset($args['options'])) {\n            $args[1] = $args['options'];\n        }\n\n        if (!empty($args[1])) {\n            if (!empty($args[1]['plugin'])) {\n                $options = ['element' => $args[1]['plugin'] . '.' . $element];\n                unset($args[1]['plugin']);\n            }\n            $options += (array)$args[1];\n        }\n\n        $this->set($args[0] ?? $args['message'], $options);\n    }","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/cakephp/cakephp/blob/1128eba9b09f1946df684811350e26f2cef68fac/src/Controller/Component/FlashComponent.php#L153-L189","documentation":"FlashComponent::__call() magic methods (e.g. $this->Flash->success(...)) convert the method name into an element name and expect the first argument to be the flash message. When called with zero arguments there is no message to render, so InternalErrorException 'Flash message missing.' is thrown.","triggerScenarios":"Calling $this->Flash->success() / error() / customElementName() with no arguments, or calling a dynamic flash method with only an options array as the sole argument.","commonSituations":"Refactoring that removed the message string, intending to set options only but passing them as the first (message) position, typos that route to __call instead of a real method.","solutions":["Pass the message string as the first argument: $this->Flash->success('Saved.')","Pass options as the second argument: $this->Flash->success('Saved.', ['params' => ...])","Use the component's set() method explicitly when you need full control","Check calls where the message may be a variable that is empty/null — pass a default"],"exampleFix":"// before\n$this->Flash->error();\n// after\n$this->Flash->error(__('Could not save record.'), ['clear' => true]);","handlingStrategy":"validation","validationCode":"if (func_num_args() < 1) {\n    throw new \\LogicException('Flash call requires a message argument');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $this->Flash->{$type}($message);\n} catch (InternalErrorException $e) {\n    $this->Flash->set('Something happened.');\n}","preventionTips":["Never call magic Flash methods with zero arguments","Pass message + options in the documented order (message first)","Route complex flash payloads through FlashComponent::set() instead"],"tags":["php","cakephp","flash-messages","controller"],"backgroundTag":"missing-required-argument","analyzedSha":"1128eba9b09f1946df684811350e26f2cef68fac","analyzedAt":"2026-09-12T12:07:00.388Z","contentChangedAt":"2026-09-12T12:07:00.388Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}