ruvnet/ruflo · error · Error

Invalid JSON in import file

Error message

Invalid JSON in import file: ${resolved}

What it means

importFrom() found the import file but JSON.parse threw on its contents, meaning the file is not valid JSON (truncated export, hand-edited file, wrong format). The catch converts the parse SyntaxError into this clearer error naming the offending resolved path before any config is applied.

Solutions

  1. Validate the file with a JSON parser (e.g. jq) before importing
  2. Fix the syntax error at the reported location

Example fix

Validate the file content with `jq . <file>` or `node -e 'JSON.parse(require("fs").readFileSync("<file>","utf8"))'` and fix the JSON syntax error before re-importing.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at v3/@claude-flow/cli/src/services/config-file-manager.ts:161 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/2057aaa9b21aa222. Report an issue: GitHub.

Appendix: source

Thrown at v3/@claude-flow/cli/src/services/config-file-manager.ts:161

  /** Export config to a specific path */
  exportTo(cwd: string, exportPath: string): void {
    const config = this.getConfig(cwd);
    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 };

View on GitHub (pinned to fa13ee4ad6)