windmill-labs/windmill · warning

${existingName} couldn't be auto-edited (it may contain comm

Error message

${existingName} couldn't be auto-edited (it may contain comments). Add ${opts.hint} to pick up wmill's recommended settings (incl. workspace /f/, /u/ import resolution).

What it means

ensureUserReferencesManaged (called from refreshManagedTsconfig / refreshManagedDenoImportMap) only rewrites tsconfig.json (or the Deno import map) it can round-trip as plain JSON. Files containing comments (JSONC) fail JSON.parse, so instead of corrupting them wmill warns and skips the edit, telling you the setting to add manually via opts.hint.

Source

Thrown at cli/src/commands/refresh/tsconfig.ts:352

  try {
    text = readFileSync(existing, "utf-8");
  } catch {
    return;
  }
  if (text.includes(opts.token)) {
    log.info(
      colors.gray(`${existingName} already references ${opts.token}, leaving it untouched`)
    );
    return;
  }

  // We only ever rewrite a config we can round-trip as JSON. Files with comments
  // (JSONC) fail JSON.parse, so we warn instead of corrupting them.
  let parsed: Record<string, unknown>;
  try {
    parsed = JSON.parse(text);
  } catch {
    log.warn(
      `${existingName} couldn't be auto-edited (it may contain comments). Add ${opts.hint} ` +
        `to pick up wmill's recommended settings (incl. workspace /f/, /u/ import resolution).`
    );
    return;
  }

  // The file is still exactly what a previous CLI generated → it's ours, so
  // migrate it to the new split (replace with the thin stub that extends the
  // managed file). No prompt: we're not touching user-authored content.
  if (opts.legacyFormats?.some((fmt) => deepEqual(parsed, fmt))) {
    writeFileSync(existing, JSON.stringify(opts.create, null, 2) + "\n");
    log.info(
      colors.green(
        `Migrated previously-generated ${existingName} to reference ${opts.token}`
      )
    );
    return;
  }

View on GitHub (pinned to e474e8803c)

Solutions

  1. Remove all // and /* */ comments (and trailing commas) from the config file so it is valid JSON, then rerun wmill refresh.
  2. Apply the setting named in opts.hint manually to the file (it enables wmill's recommended settings incl. workspace /f/, /u/ import resolution).
  3. Let wmill recreate the file: move the old one aside and rerun refresh so it writes a managed version.
  4. Keep future edits JSON-only in files managed by wmill, or maintain comments in a separate doc.

Example fix

// before: tsconfig.json
{
  // my note
  "compilerOptions": { ... }
}
// after
{
  "compilerOptions": { ... }
}
Defensive patterns

Strategy: validation

Validate before calling

// verify the config is strict JSON before running wmill refresh
import { readFileSync } from 'fs';
try {
  JSON.parse(readFileSync('tsconfig.json', 'utf-8'));
  console.log('tsconfig.json is valid JSON — refresh can manage it');
} catch (e) {
  console.error('tsconfig.json is JSONC/invalid:', e.message);
}

Type guard

function isPlainJson(text) { try { JSON.parse(text); return true; } catch { return false; } }

Prevention

When it happens

Trigger: Running `wmill refresh` (managed tsconfig/import-map refresh) when the existing tsconfig.json or deno import map contains comments or trailing commas, so JSON.parse throws.

Common situations: Hand-edited tsconfig with // comments (common in editors that tolerate JSONC); a tool-generated config with comments; configs copied from templates that use JSONC syntax.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/8ffc318bb9da9447. Report an issue: GitHub.