Currently scripts/lib/schema.mjs loads YAML with no error handling:
function loadYaml(path) {
return yaml.load(readFileSync(path, "utf8"));
}
When working/profile.yaml or working/criteria.yaml is malformed (a stray tab, bad indentation, missing colon), the user gets a raw YAMLException from js-yaml with no file context — just something like bad indentation of a mapping entry at line 25, column 5. They have to guess which file broke.
Task: wrap loadYaml() in scripts/lib/schema.mjs to catch YAMLException and re-throw with file-aware context. js-yaml's YAMLException exposes .mark with line, column, and name properties — use these to build a friendly message.
Expected message shape:
Couldn't parse working/profile.yaml — bad indentation at line 25, column 5.
Check the YAML syntax around that line.
Acceptance:
- Intentionally break
working/profile.yaml (add a stray tab, drop a colon, etc.)
- Run any script that loads YAML (e.g. via
/argopia-survey)
- User sees a friendly message naming the file and the offending line/column — not a raw stack trace
- All other call sites of
loadYaml() benefit automatically (it's the single chokepoint)
Scope: scripts/lib/schema.mjs is the only file that needs changing. No new dependencies.
Currently
scripts/lib/schema.mjsloads YAML with no error handling:When
working/profile.yamlorworking/criteria.yamlis malformed (a stray tab, bad indentation, missing colon), the user gets a rawYAMLExceptionfrom js-yaml with no file context — just something likebad indentation of a mapping entry at line 25, column 5. They have to guess which file broke.Task: wrap
loadYaml()inscripts/lib/schema.mjsto catchYAMLExceptionand re-throw with file-aware context. js-yaml'sYAMLExceptionexposes.markwithline,column, andnameproperties — use these to build a friendly message.Expected message shape:
Acceptance:
working/profile.yaml(add a stray tab, drop a colon, etc.)/argopia-survey)loadYaml()benefit automatically (it's the single chokepoint)Scope:
scripts/lib/schema.mjsis the only file that needs changing. No new dependencies.