ruvnet/ruflo · error · Error
Import file must contain a JSON object
Error message
Import file must contain a JSON object
What it means
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.
Solutions
- Wrap the configuration content in a JSON object {} rather than an array or scalar
Example fix
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. Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at v3/@claude-flow/cli/src/services/config-file-manager.ts:164 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/2de571016fb6f1aa.
Report an issue: GitHub.
Appendix: source
Thrown at v3/@claude-flow/cli/src/services/config-file-manager.ts:164
const resolved = path.resolve(cwd, exportPath);
this.writeAtomic(resolved, config);
}
/** Import config from a specific path */
importFrom(cwd: string, importPath: string): void {
const resolved = path.resolve(cwd, importPath);
if (!fs.existsSync(resolved)) {
throw new Error(`Import file not found: ${resolved}`);
}
const content = fs.readFileSync(resolved, 'utf-8');
let imported: Record<string, unknown>;
try {
imported = JSON.parse(content);
} catch {
throw new Error(`Invalid JSON in import file: ${resolved}`);
}
if (typeof imported !== 'object' || imported === null || Array.isArray(imported)) {
throw new Error('Import file must contain a JSON object');
}
const targetPath = this.configPath ?? path.resolve(cwd, CONFIG_FILENAMES[0]);
this.writeAtomic(targetPath, imported);
this.config = imported;
this.configPath = targetPath;
}
/** Get the path to the current config file */
getConfigPath(): string | null {
return this.configPath;
}
/** Get default config */
getDefaults(): Record<string, unknown> {
return { ...DEFAULT_CONFIG };
}
/** Atomic write: write to .tmp then rename */View on GitHub (pinned to fa13ee4ad6)