{"record":{"id":"f06b856e1f73b8c9","repo":"octobercms/october","slug":"import-script-is-missing-definition-for-class","errorCode":null,"errorMessage":"Import script is missing definition for 'class'","messagePattern":"Import script is missing definition for 'class'","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/cms/models/ThemeSeed.php","lineNumber":214,"sourceCode":"\n        foreach ($instructions as $instruction) {\n            $this->processSeedInstruction($instruction);\n        }\n    }\n\n    /**\n     * processSeedInstruction\n     */\n    protected function processSeedInstruction($instruction)\n    {\n        $importName = $instruction['name'] ?? 'Import Data';\n        $className = $instruction['class'] ?? null;\n        $fileName = $instruction['file'] ?? null;\n        $attributes = $instruction['attributes'] ?? null;\n        $matches = $instruction['matches'] ?? null;\n\n        if (!$className) {\n            throw new SystemException(\"Import script is missing definition for 'class'\");\n        }\n        if (!$fileName) {\n            throw new SystemException(\"Import script is missing definition for 'file'\");\n        }\n        if (!$attributes || !is_array($attributes)) {\n            throw new SystemException(\"Import script is missing definition for 'attributes'\");\n        }\n\n        if (!class_exists($className)) {\n            throw new SystemException(\"Import class '{$className}' does not exist.\");\n        }\n\n        $importFile = $this->themePath . '/' . $fileName;\n        if (!File::exists($importFile)) {\n            throw new SystemException(\"Import file '{$fileName}' does not exist.\");\n        }\n\n        $importModel = new $className;","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/cms/models/ThemeSeed.php#L196-L232","documentation":"Each entry in a theme's seeds/data.yaml must define class (the importer class to instantiate), file (the data file), and attributes. processSeedInstruction() throws this SystemException when the 'class' key is absent or null, before anything is executed - a seed-instruction schema check.","triggerScenarios":"A data.yaml instruction like { name: Pages, file: seeds/pages.yaml, attributes: [title] } with no class key, or class: with an empty value, run through theme:seed or activation seeding.","commonSituations":"Hand-written seed files copied from examples that omitted the class; renaming the key (className instead of class); YAML indentation putting class under a sibling key.","solutions":["Add a fully-qualified 'class' value to the failing instruction in seeds/data.yaml (it must be an importer that supports importFile).","Confirm the class resolves before re-seeding: class_exists('Acme\\Blog\\Classes\\PostImport').","Re-run php artisan theme:seed <theme>."],"exampleFix":"# before (themes/demo/seeds/data.yaml)\n- name: Blog posts\n  file: seeds/posts.yaml\n  attributes: [title, content]\n\n# after\n- name: Blog posts\n  class: 'Acme\\Blog\\Classes\\PostImport'\n  file: seeds/posts.yaml\n  attributes: [title, content]","handlingStrategy":"validation","validationCode":"use Symfony\\Component\\Yaml\\Yaml;\nuse File;\n\nfunction seedInstructionsValid(string $themePath): array\n{\n    $errors = [];\n    $file = $themePath . '/seeds/data.yaml';\n    if (!File::isFile($file)) return $errors;\n    foreach ((array) Yaml::parseFile($file) as $i => $ins) {\n        if (empty($ins['class'])) $errors[] = \"instruction {$i}: missing 'class'\";\n    }\n    return $errors;\n}","typeGuard":"function isCompleteSeedInstruction(array $i): bool\n{\n    return isset($i['class']) && $i['class'] !== '';\n}","tryCatchPattern":"try {\n    \\Artisan::call('theme:seed', ['name' => $themeDir]);\n} catch (\\October\\Rain\\Exception\\SystemException $e) {\n    // message names the missing key; fix that entry in seeds/data.yaml\n}","preventionTips":["Validate seeds/data.yaml structure in CI with a schema check script.","Start from a known-good example instruction and never delete the class line.","Re-run seeding after each edit to catch schema errors early."],"tags":["theme-seed","yaml","config-validation","missing-key"],"backgroundTag":"missing-required-config-key","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}