{"record":{"id":"20a917eac6e80317","repo":"octobercms/october","slug":"import-script-is-missing-definition-for-file","errorCode":null,"errorMessage":"Import script is missing definition for 'file'","messagePattern":"Import script is missing definition for 'file'","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/cms/models/ThemeSeed.php","lineNumber":217,"sourceCode":"        }\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;\n        $importModel->forceFill($attributes);\n\n        if (method_exists($importModel, 'setSourcePrefix')) {","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/cms/models/ThemeSeed.php#L199-L235","documentation":"Same seed-instruction schema check as the missing-class error, but for the 'file' key: processSeedInstruction() requires every data.yaml instruction to name the data file (resolved relative to the theme directory) that the importer will read. A missing or null file key aborts seeding before any class is loaded.","triggerScenarios":"A data.yaml entry with class and attributes but no file key (or file: left empty), processed by theme:seed; typically after trimming an example down or a copy-paste that dropped the line.","commonSituations":"Seed files authored from scratch following older docs; key spelled files instead of file; empty value from a YAML templating step.","solutions":["Add the 'file' key pointing at the data file relative to the theme root, e.g. file: seeds/posts.yaml.","Verify the path exists on disk: File::exists($themePath.'/seeds/posts.yaml').","Re-run php artisan theme:seed <theme>."],"exampleFix":"# before\n- name: Blog posts\n  class: 'Acme\\Blog\\Classes\\PostImport'\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":"foreach ((array) Yaml::parseFile($themePath . '/seeds/data.yaml') as $i => $ins) {\n    if (empty($ins['file'])) {\n        $errors[] = \"instruction {$i}: missing 'file'\";\n    }\n}","typeGuard":"function isCompleteSeedInstruction(array $i): bool\n{\n    return isset($i['file']) && $i['file'] !== '';\n}","tryCatchPattern":"try {\n    \\Artisan::call('theme:seed', ['name' => $themeDir]);\n} catch (\\October\\Rain\\Exception\\SystemException $e) {\n    // add the 'file' key to the flagged instruction, then re-seed\n}","preventionTips":["Require all three keys (class, file, attributes) in your seed-file linter.","Keep instruction examples intact when copying - the file line is easy to drop.","Confirm the referenced file ships with the theme."],"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"}