{"record":{"id":"2de571016fb6f1aa","repo":"ruvnet/ruflo","slug":"import-file-must-contain-a-json-object","errorCode":null,"errorMessage":"Import file must contain a JSON object","messagePattern":"Import file must contain a JSON object","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/services/config-file-manager.ts","lineNumber":164,"sourceCode":"    const resolved = path.resolve(cwd, exportPath);\n    this.writeAtomic(resolved, config);\n  }\n\n  /** Import config from a specific path */\n  importFrom(cwd: string, importPath: string): void {\n    const resolved = path.resolve(cwd, importPath);\n    if (!fs.existsSync(resolved)) {\n      throw new Error(`Import file not found: ${resolved}`);\n    }\n    const content = fs.readFileSync(resolved, 'utf-8');\n    let imported: Record<string, unknown>;\n    try {\n      imported = JSON.parse(content);\n    } catch {\n      throw new Error(`Invalid JSON in import file: ${resolved}`);\n    }\n    if (typeof imported !== 'object' || imported === null || Array.isArray(imported)) {\n      throw new Error('Import file must contain a JSON object');\n    }\n    const targetPath = this.configPath ?? path.resolve(cwd, CONFIG_FILENAMES[0]);\n    this.writeAtomic(targetPath, imported);\n    this.config = imported;\n    this.configPath = targetPath;\n  }\n\n  /** Get the path to the current config file */\n  getConfigPath(): string | null {\n    return this.configPath;\n  }\n\n  /** Get default config */\n  getDefaults(): Record<string, unknown> {\n    return { ...DEFAULT_CONFIG };\n  }\n\n  /** Atomic write: write to .tmp then rename */","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/services/config-file-manager.ts#L146-L182","documentation":"importFrom() parsed the file successfully but the top-level value is not a plain JSON object (e.g. an array, string, or number), so it cannot be merged as a config map. The typeof check on the parsed result guards the downstream spread/merge that assumes a key-value object.","triggerScenarios":"Thrown at v3/@claude-flow/cli/src/services/config-file-manager.ts:164 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wrap the configuration content in a JSON object {} rather than an array or scalar"],"exampleFix":"Ensure the import file's top-level JSON value is an object ({...}), not an array or scalar. Wrap the data in an object if needed.","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}