tobi/qmd · error · Error
Failed to parse ${configPath}: ${error}
Error message
Failed to parse ${configPath}: ${error} What it means
loadConfig failed while reading the QMD YAML config file. The file exists but its contents could not be parsed as YAML (or the parsed result was unusable), so the raw parser error is wrapped with the offending path. This is thrown from loadConfig, which backs config loading for the CLI and createStore.
Source
Thrown at src/collections.ts:202
// File-based config (SDK custom path or default)
const configPath = configSource.path || getConfigFilePath();
if (!existsSync(configPath)) {
return { collections: {} };
}
try {
const content = readFileSync(configPath, "utf-8");
const parsed = YAML.parse(content) as CollectionConfig | null | undefined;
const config = parsed ?? { collections: {} };
// Ensure collections object exists
if (!config.collections) {
config.collections = {};
}
return config;
} catch (error) {
throw new Error(`Failed to parse ${configPath}: ${error}`);
}
}
/**
* Save configuration to the configured source.
* - Inline config: updates the in-memory object (no file I/O)
* - File-based: writes to YAML file (default ~/.config/qmd/index.yml)
*/
export function saveConfig(config: CollectionConfig): void {
// SDK inline config mode: update in place, no file I/O
if (configSource.type === 'inline') {
configSource.config = config;
return;
}
const configPath = configSource.path || getConfigFilePath();
const configDir = dirname(configPath);
if (!existsSync(configDir)) {View on GitHub (pinned to dbfd0b4736)
Solutions
- Run `qmd doctor` to diagnose config issues
- Inspect the file named in the message with a YAML linter and fix indentation/quotes
- If unsure, delete the corrupt config and regenerate with `qmd collection add` or `qmd init`
- Keep configs out of manual edits; use qmd CLI commands to mutate them
Example fix
# before (broken)
collections:
notes:
path: ~/notes # bad indentation
# after
collections:
notes:
path: ~/notes
Defensive patterns
Strategy: validation
Validate before calling
import { readFileSync } from 'node:fs';
import { parse } from 'yaml';
function configLooksValid(configPath: string): boolean {
try { parse(readFileSync(configPath, 'utf-8')); return true; }
catch { return false; }
} Try / catch
try {
const store = await createStore({ dbPath, configPath });
} catch (e) {
if (e instanceof Error && e.message.startsWith('Failed to parse')) {
console.error('Config syntax error:', e.message);
} else throw e;
} Prevention
- Validate config YAML in CI before deploying
- Let qmd CLI commands mutate the config instead of hand editing
- Keep the config under version control to diff breakage
When it happens
Trigger: Calling createStore({configPath: './qmd.yaml'}) or any qmd CLI command when the YAML config has a syntax error: bad indentation, unclosed quote, tabs, or pasted markdown mixed into the YAML.
Common situations: Hand-editing ~/.config/qmd/config.yaml or a project .qmd config and breaking YAML syntax; merging config changes via git producing conflicts left in the file; empty file with invalid BOM or non-UTF8 bytes.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Collection name is required. Collections must be defined in
- Failed to write ${configPath}: ${error}
- Invalid expandContextSize: ${configValue}. Must be a positiv
- [qmd] AST parse failed for ${filepath}, falling back to rege
AI-assisted analysis of tobi/qmd@dbfd0b4736 (2026-08-28).
Data as JSON: /api/errors/ec1b8385deb81dbe.
Report an issue: GitHub.