Yeachan-Heo/oh-my-codex · error · Error

Refusing to write invalid planned config.toml: ${error insta

Error message

Refusing to write invalid planned config.toml: ${error instanceof Error ? error.message : String(error)}

What it means

After composing the final config.toml, the planner re-parses it with TOML.parse as a safety check; the generated TOML is invalid, so it refuses to write a broken config. The parser's message explains the syntax problem.

Source

Thrown at src/cli/setup.ts:3906

					notifyPlan.metadataPath,
					`notification metadata ${notifyPlan.metadataPath}`,
					metadataBefore,
				);
			}
		}
	}

	if (!options.disableHooks && options.isPluginInstallMode && options.sharedMcpRegistry.servers.length > 0) {
		finalConfig = mergeSharedMcpRegistryBlock(
			finalConfig,
			options.sharedMcpRegistry.servers,
			options.sharedMcpRegistry.sourcePath,
		);
	}
	try {
		TOML.parse(finalConfig);
	} catch (error) {
		throw new Error(
			`Refusing to write invalid planned config.toml: ${error instanceof Error ? error.message : String(error)}`,
		);
	}

	const hookArtifact = nativeHookTransactionArtifact(
		"hooks",
		options.hooksPath,
		`native hooks ${options.hooksPath}`,
		existingHooksSnapshot,
		finalHooksContent === null ? null : Buffer.from(finalHooksContent, "utf-8"),
		options.platform,
	);
	const configArtifact = nativeHookTransactionArtifact(
		"config",
		options.configPath,
		`config ${options.configPath}`,
		existingConfigSnapshot,
		Buffer.from(finalConfig, "utf-8"),

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Inspect the generated config for unescaped quotes/newlines in string values; simplify the offending entry in your original config.toml
  2. Report the issue to OMX maintainers with your (redacted) config.toml — a valid input config should always round-trip
  3. As a workaround, remove/rename the problematic config section and re-run setup, then re-add it manually
Defensive patterns

Strategy: validation

Validate before calling

import TOML from '@iarna/toml';
try { TOML.parse(readFileSync(configPath, 'utf8')); } catch { /* sanitize or fix config before running setup */ }

Try / catch

catch (e) { if (String(e).startsWith('Refusing to write invalid planned config.toml')) { /* inspect config values with quotes/newlines; report bug */ } else throw e; }

Prevention

When it happens

Trigger: User config content (e.g. a pre-existing notify command, MCP entries, or string values containing newlines/quotes) gets serialized into TOML that fails to round-trip through the TOML parser.

Common situations: Multi-line or unescaped special characters in existing config values, exotic TOML from an older Codex version, or a serialization bug in OMX itself.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/c0ca2cfccf7d5aa0. Report an issue: GitHub.