can1357/oh-my-pi · error · Error

isEnoent(error) ? `Config overlay not found: ${filePath}` :

Error message

isEnoent(error) ? `Config overlay not found: ${filePath}` : `Failed to read config overlay ${filePath}: ${String(error)}`

What it means

Thrown by #loadOverlayYaml when a config overlay file (an explicit, required overlay path) cannot be read. If the error is ENOENT the message is "Config overlay not found"; any other I/O error yields "Failed to read config overlay" with the underlying error. Unlike the main settings file, overlays are explicitly requested, so a missing file is an error rather than a default.

Source

Thrown at packages/coding-agent/src/config/settings.ts:1587

	}

	async #loadConfigOverlays(): Promise<RawSettings> {
		const result = await this.#readConfigOverlays();
		this.#overlayShellPathSource = result.shellPathSource;
		return result.settings;
	}

	/**
	 * Strict loader for explicit `--config` overlays: unlike `#loadYaml`,
	 * missing or malformed files are hard errors so a typo'd path cannot
	 * silently fall back to the persistent settings.
	 */
	async #loadOverlayYaml(filePath: string, captureLegacyChangelogVersion = true): Promise<RawSettings> {
		let content: string;
		try {
			content = await Bun.file(filePath).text();
		} catch (error) {
			throw new Error(
				isEnoent(error)
					? `Config overlay not found: ${filePath}`
					: `Failed to read config overlay ${filePath}: ${String(error)}`,
			);
		}
		let parsed: unknown;
		try {
			parsed = YAML.parse(content);
		} catch (error) {
			throw new Error(`Failed to parse config overlay ${filePath}: ${String(error)}`);
		}
		if (parsed === null || parsed === undefined) return {};
		if (typeof parsed !== "object" || Array.isArray(parsed)) {
			throw new Error(`Config overlay must be a YAML mapping: ${filePath}`);
		}
		return this.#migrateRawSettings(parsed as RawSettings, captureLegacyChangelogVersion);
	}

View on GitHub (pinned to 9690622007)

Solutions

  1. Check the path in the message for typos and correct it
  2. Create the overlay file if it is supposed to exist
  3. Use an absolute path to avoid working-directory ambiguity
  4. If the error is not 'not found', fix file permissions or remove the directory occupying the path

Example fix

// before
omp --config-overlay ./confg-overrides.yaml
// after
omp --config-overlay ./config-overrides.yaml
Defensive patterns

Strategy: try-catch

Validate before calling

import { isEnoent } from '@oh-my-pi/pi-utils';
async function overlayExists(p) { try { await Bun.file(p).text(); return true; } catch (e) { return !isEnoent(e); } }

Try / catch

try { const overlay = await loadOverlay(p); } catch (e) {
  if (String(e).startsWith('Config overlay not found')) { logger.error('Overlay path wrong or file missing', { path: p }); }
  else if (String(e).startsWith('Failed to read config overlay')) { logger.error('Overlay unreadable', { path: p }); }
  else throw e;
}

Prevention

When it happens

Trigger: Loading a user-specified overlay path that does not exist (ENOENT), or that exists but is unreadable (EACCES, EISDIR, etc.).

Common situations: Typo in the --config-overlay / overlay path argument; overlay file deleted or renamed after being referenced; relative path resolved from a different working directory than expected.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/05ff5faab871f590. Report an issue: GitHub.