{"record":{"id":"eb6e88916ecd7d29","repo":"octobercms/october","slug":"missing-section-definition-call-entryrecord-inse","errorCode":null,"errorMessage":"Missing section definition. Call EntryRecord::inSection() to set one.","messagePattern":"Missing section definition\\. Call EntryRecord::inSection\\(\\) to set one\\.","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/tailor/models/entryrecord/HasEntryBlueprint.php","lineNumber":50,"sourceCode":"        });\n\n        $this->bindEvent('model.newInstance', function($model) {\n            $model->extendWithBlueprint($this->blueprint_uuid);\n        });\n    }\n\n    /**\n     * getBlueprintDefinition\n     */\n    public function getBlueprintDefinition(): EntryBlueprint\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 section definition. Call EntryRecord::inSection() to set one.');\n        }\n\n        $blueprint = BlueprintIndexer::instance()->findSection($uuid);\n        if (!$blueprint) {\n            throw new SystemException(sprintf('Unable to find section blueprint with ID \"%s\".', $uuid));\n        }\n\n        return $this->blueprintCache = $blueprint;\n    }\n\n    /**\n     * isEntryStructure\n     */\n    public function isEntryStructure(): bool\n    {\n        return $this->getBlueprintDefinition() instanceof StructureBlueprint;\n    }\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/tailor/models/entryrecord/HasEntryBlueprint.php#L32-L68","documentation":"Thrown by the getBlueprintDefinition() method on entry records (HasEntryBlueprint trait) when the model instance has no blueprint_uuid attribute set. Every Tailor entry must belong to a section; the UUID is normally assigned when querying via EntryRecord::inSection()/inSectionUuid() or when the record is created through Tailor. Directly instantiating an EntryRecord without a section triggers this SystemException.","triggerScenarios":"Doing new EntryRecord or EntryRecord::create([...]) without going through inSection()/inSectionUuid(), or calling blueprint-dependent methods (fieldset, content fields, isEntryStructure) on an unattached instance; also when fetched rows lose their blueprint_uuid (null in the database).","commonSituations":"Custom code that mass-creates or queries entry records directly instead of using the section-scoped APIs; seeding scripts that insert EntryRecord rows without blueprint_uuid; data corruption after partial imports.","solutions":["Always obtain models through section APIs: EntryRecord::inSection('handle') for querying, or use the section's newModelInstance() for creating","When creating records programmatically, set the blueprint UUID: $model->blueprint_uuid = $blueprint->uuid before save, or use inSectionUuid to scope the query so the UUID is applied","Fix rows with a null blueprint_uuid in the database by reassigning the correct section UUID","For singular sections, use findSingleForSection() which handles creation for you"],"exampleFix":"// before\n$record = new \\Tailor\\Models\\EntryRecord;\n$record->title = 'Test';\n$record->save();  // later blueprint access throws\n\n// after\n$blueprint = \\Tailor\\Classes\\BlueprintIndexer::instance()->findSectionByHandle('blog_post');\n$record = $blueprint->newModelInstance();\n$record->title = 'Test';\n$record->save();","handlingStrategy":"validation","validationCode":"// Ensure the instance is section-attached before blueprint use\nif (empty($model->blueprint_uuid)) {\n    $blueprint = \\Tailor\\Classes\\BlueprintIndexer::instance()->findSectionByHandle('blog_post');\n    $model->blueprint_uuid = $blueprint->uuid;\n}","typeGuard":"function isSectionAttached(\\Tailor\\Models\\EntryRecord $record): bool\n{\n    return !empty($record->blueprint_uuid);\n}","tryCatchPattern":null,"preventionTips":["Always create and query entries through EntryRecord::inSection()/inSectionUuid() or the blueprint's newModelInstance()","Never insert entry rows directly via DB facade without setting blueprint_uuid","Add a NOT NULL awareness in seeders: every entry row needs a valid blueprint UUID"],"tags":["tailor","octobercms","blueprint","entry-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"}