{"record":{"id":"2fc13d6f97e0cfa9","repo":"octobercms/october","slug":"missing-global-definition-call-globalrecord-ingl","errorCode":null,"errorMessage":"Missing global definition. Call GlobalRecord::inGlobal() to set one.","messagePattern":"Missing global definition\\. Call GlobalRecord::inGlobal\\(\\) to set one\\.","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/tailor/models/globalrecord/HasGlobalBlueprint.php","lineNumber":76,"sourceCode":"     * globalBeforeSaveDone\n     */\n    public function globalBeforeSaveDone()\n    {\n        $this->storeBlueprintContent();\n    }\n\n    /**\n     * getBlueprintDefinition\n     */\n    public function getBlueprintDefinition(): GlobalBlueprint\n    {\n        if ($this->blueprintCache !== null) {\n            return $this->blueprintCache;\n        }\n\n        $uuid = $this->blueprint_uuid;\n        if (!$uuid) {\n            throw new SystemException('Missing global definition. Call GlobalRecord::inGlobal() to set one.');\n        }\n\n        $blueprint = BlueprintIndexer::instance()->findGlobal($uuid);\n        if (!$blueprint) {\n            throw new SystemException(sprintf('Unable to find global blueprint with ID \"%s\".', $uuid));\n        }\n\n        return $this->blueprintCache = $blueprint;\n    }\n\n    /**\n     * fetchBlueprintContent\n     */\n    public function fetchBlueprintContent()\n    {\n        $content = $this->content;\n        $contentColumns = $this->getFieldsetColumnNames();\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/tailor/models/globalrecord/HasGlobalBlueprint.php#L58-L94","documentation":"Thrown by getBlueprintDefinition() on global records (HasGlobalBlueprint trait) when the model instance has no blueprint_uuid attribute. Global records must be attached to a global blueprint via GlobalRecord::inGlobal()/inGlobalUuid() before blueprint-dependent APIs are used; a SystemException is raised when the UUID is missing.","triggerScenarios":"Instantiating GlobalRecord directly (new GlobalRecord) and calling methods that need the blueprint (content fields, fieldset definitions); creating global rows without the blueprint UUID; accessing blueprint APIs on rows whose blueprint_uuid is null.","commonSituations":"Seeding or import scripts creating global records outside the Tailor APIs; custom code copying global records between sites without preserving blueprint_uuid.","solutions":["Use GlobalRecord::inGlobal('handle') / findForGlobal('handle') to obtain properly attached models","When creating programmatically, resolve the blueprint first and set the UUID on the instance before save","Repair rows with null blueprint_uuid by assigning the intended global blueprint's UUID"],"exampleFix":"// before\n$global = new \\Tailor\\Models\\GlobalRecord;\n$global->save();  // blueprint access later throws\n\n// after\n$blueprint = \\Tailor\\Classes\\BlueprintIndexer::instance()->findGlobalByHandle('site_settings');\n$global = \\Tailor\\Models\\GlobalRecord::findForGlobalUuid($blueprint->uuid);","handlingStrategy":"validation","validationCode":"if (empty($global->blueprint_uuid)) {\n    $blueprint = \\Tailor\\Classes\\BlueprintIndexer::instance()->findGlobalByHandle('site_settings');\n    $global->blueprint_uuid = $blueprint->uuid;\n}","typeGuard":"function isGlobalAttached(\\Tailor\\Models\\GlobalRecord $record): bool\n{\n    return !empty($record->blueprint_uuid);\n}","tryCatchPattern":null,"preventionTips":["Obtain global records only via GlobalRecord::inGlobal()/findForGlobal() so the UUID is always set","Write seeders through the section/global APIs rather than raw inserts","Copy blueprint_uuid when duplicating global records across sites"],"tags":["tailor","octobercms","blueprint","global-record","uuid","api-misuse"],"backgroundTag":"missing-parent-association","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}