{"record":{"id":"4b20e1354db5a1cd","repo":"toeverything/AFFiNE","slug":"a-config-file-path-is-required","errorCode":null,"errorMessage":"A config file path is required","messagePattern":"A config file path is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/backend/server/src/data/commands/import.ts","lineNumber":20,"sourceCode":"import { resolve } from 'node:path';\n\nimport { Injectable, Logger } from '@nestjs/common';\n\nimport { ConfigFactory, InvalidAppConfigInput } from '../../base';\nimport { Models } from '../../models';\n\n@Injectable()\nexport class ImportConfigCommand {\n  logger = new Logger(ImportConfigCommand.name);\n\n  constructor(\n    private readonly models: Models,\n    private readonly configFactory: ConfigFactory\n  ) {}\n\n  async execute(path?: string): Promise<void> {\n    if (!path) {\n      throw new Error('A config file path is required');\n    }\n\n    path = resolve(process.cwd(), path);\n\n    const overrides: Record<string, Record<string, any>> = JSON.parse(\n      readFileSync(path, 'utf-8')\n    );\n\n    const forValidation: { module: string; key: string; value: any }[] = [];\n    const forSaving: { key: string; value: any }[] = [];\n    Object.entries(overrides).forEach(([module, config]) => {\n      if (module === '$schema') {\n        return;\n      }\n\n      Object.entries(config).forEach(([key, value]) => {\n        forValidation.push({\n          module,","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/server/src/data/commands/import.ts#L2-L38","documentation":"Thrown by ImportConfigCommand.execute(path?) — the 'data import-config' CLI command — when no path argument was supplied. The command needs a JSON config file to read overrides from, so an undefined path is a usage error.","triggerScenarios":"Running the server CLI import command without the config file path argument, e.g. 'node cli.js data import-config' with nothing after it.","commonSituations":"Wrong CLI subcommand spelling so the path is parsed as another flag; shell script omitted the argument; copy-pasted docs example without filling in the path.","solutions":["Pass the config file path: run the import command with the JSON file as its argument (absolute or cwd-relative path).","Check 'node cli.js data --help' (or the command help) for the exact argument position of the path.","Ensure the path has no unquoted spaces breaking it into multiple argv entries."],"exampleFix":"// before\n$ node cli.js data import-config\n// after\n$ node cli.js data import-config ./config-overrides.json","handlingStrategy":"validation","validationCode":"// In a CLI wrapper, check argv before invoking the command\nconst path = argv._[1];\nassert(typeof path === 'string' && path.length > 0, 'config file path is required');\nawait importConfigCommand.execute(path);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrap the CLI in a script that asserts the path argument exists before calling execute().","Use the command's help output to lock in the exact argument order."],"tags":["cli","config","import","argument"],"backgroundTag":"missing-cli-argument","analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}