{"record":{"id":"dcdfbc74e8d380d5","repo":"getgrav/grav","slug":"flash-has-no-object","errorCode":null,"errorMessage":"Flash has no object","messagePattern":"Flash has no object","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"system/src/Grav/Framework/Flex/FlexForm.php","lineNumber":168,"sourceCode":"        $this->messages = [];\n        $this->submitted = false;\n        $this->data = null;\n        $this->files = [];\n        $this->unsetFlash();\n\n        /** @var FlexFormFlash $flash */\n        $flash = $this->getFlash();\n        if ($flash->exists()) {\n            $data = $flash->getData();\n            if (null !== $data) {\n                $data = new Data($data, $this->getBlueprint());\n                $data->setKeepEmptyValues(true);\n                $data->setMissingValuesAsNull(true);\n            }\n\n            $object = $flash->getObject();\n            if (null === $object) {\n                throw new RuntimeException('Flash has no object');\n            }\n\n            $this->object = $object;\n            $this->data = $data;\n\n            $includeOriginal = (bool)($this->getBlueprint()->form()['images']['original'] ?? null);\n            $this->files = $flash->getFilesByFields($includeOriginal);\n        }\n\n        return $this;\n    }\n\n    /**\n     * @param string $uniqueId\n     * @return void\n     */\n    public function setUniqueId(string $uniqueId): void\n    {","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Grav/Framework/Flex/FlexForm.php#L150-L186","documentation":"When a FlexForm initializes and its FlexFormFlash exists, the flash must carry an object: FlexFormFlash::init() rebuilds it from config or from the stored 'object.serialized' data. If the flash JSON has no serialized object (directory-only flash) or the flex type is no longer registered, getObject() returns null and this RuntimeException is thrown. It is a session-state mismatch between the flash and the current form.","triggerScenarios":"A flash created for a directory-level form (stores only directory type) being consumed by an object-level FlexForm with the same unique id; the flex type renamed/removed between form submission and re-render; flash file from an older Grav schema without the object.serialized block; createObject() failing silently during restore (e.g. storage key collision).","commonSituations":"Multi-step forms where step 1 initializes the flash without an object but step 2 expects one; deploys changing flex type names while admin sessions held open forms; local dev against production session data.","solutions":["Delete the stale flash (FormFlash::delete() for the form's uniqueFormId, or clear user session) so the form starts fresh.","Ensure every step that reads the form passes the same 'object'/'directory'+'key' options used when the flash was created.","Verify the flex type is registered in the current codebase before re-opening the form.","On major upgrades, bump the form unique id/name so old flashes are not reused."],"exampleFix":"// before\n$form = FlexForm::instance($options)->initialize(); // Flash has no object\n\n// after\nuse Grav\\Framework\\Form\\FormFlash;\n$flash = new FormFlash($uniqueId);\nif ($flash->exists() && $flash->getObject() === null) {\n    $flash->delete(); // stale/incompatible flash: start over\n}\n$form = FlexForm::instance($options)->initialize();","handlingStrategy":"validation","validationCode":"// Verify the flash carries an object before initializing an object form\n$flash = new \\Grav\\Framework\\Flex\\FlexFormFlash($uniqueId);\nif ($flash->exists() && $flash->getObject() === null) {\n    $flash->delete(); // cannot restore object: restart the form\n}\n$form = FlexForm::instance($options)->initialize();","typeGuard":null,"tryCatchPattern":"try {\n    $form->initialize();\n} catch (\\Grav\\Framework\\Flex\\Exception\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'Flash has no object')) {\n        $form->getFlash()->delete();\n        $form = FlexForm::instance($options)->initialize(); // clean retry\n    }\n}","preventionTips":["Use the same 'object'/'directory'+'key' options in every step of a multi-step form.","Register back-compat flex types after renames so old flashes stay resolvable.","Clear form flashes on logout and on major version upgrades.","Avoid reusing form names/unique ids across different flex types."],"tags":["grav","flex","forms","flash","session-state"],"backgroundTag":"stale-session-state","analyzedSha":"6040efed04efa69b8209448ed81308e7c24147c2","analyzedAt":"2026-08-17T05:07:31.593Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}