Skip to content

fix(heartbeat): include file path in JSON parse errors#6

Open
oratis wants to merge 1 commit into
mainfrom
fix/heartbeat-config-parse-error-5
Open

fix(heartbeat): include file path in JSON parse errors#6
oratis wants to merge 1 commit into
mainfrom
fix/heartbeat-config-parse-error-5

Conversation

@oratis
Copy link
Copy Markdown
Owner

@oratis oratis commented May 20, 2026

Closes #5.

What

loadHeartbeatConfig was the only user-config loader of the three that didn't tag JSON parse failures with the offending file path:

Loader Path Error wrap
mcp/config.ts ~/.lisa/mcp.json
channels/config.ts ~/.lisa/channels.json
heartbeat/config.ts ~/.lisa/heartbeat.json ❌ (bare `JSON.parse`)

A user with a typo in heartbeat.json got SyntaxError: Unexpected token … pointing at compiled dist/heartbeat/config.js with no hint that the problem was in their own config.

Change

Match the existing sibling pattern (same wording, same shape):

let parsed: HeartbeatConfig;
try {
  parsed = JSON.parse(raw) as HeartbeatConfig;
} catch (err) {
  throw new Error(`failed to parse ${FILE}: ${(err as Error).message}`);
}

Scope

  • One file, one function (6-line diff)
  • No public API change, no behavior change for valid configs, no new deps
  • Only the failure-path message gets better

npm run typecheck clean.

🤖 Generated with Claude Code

`loadHeartbeatConfig` was the odd one out among the three user-config
loaders — `mcp/config.ts` and `channels/config.ts` both wrap their
`JSON.parse` to surface the offending path; this one threw a bare
`SyntaxError: Unexpected token …` so a user with a typo in
`~/.lisa/heartbeat.json` would see a stack trace into our compiled
JS with no breadcrumbs back to their own config file.

Match the existing sibling pattern. Same `failed to parse <path>: <err>`
wording.

Closes #5

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

heartbeat: loadHeartbeatConfig swallows file path in JSON parse errors

1 participant