Skip to content

🐛 fix(api): return null on error so read handlers surface tidy errors + add CI#1

Merged
kud merged 1 commit into
mainfrom
fix/apifetch-error-handling-and-ci
Jul 5, 2026
Merged

🐛 fix(api): return null on error so read handlers surface tidy errors + add CI#1
kud merged 1 commit into
mainfrom
fix/apifetch-error-handling-and-ci

Conversation

@kud

@kud kud commented Jul 5, 2026

Copy link
Copy Markdown
Owner

What

Aligns apiFetch with the fleet convention (as in mcp-trakt): it now returns null on non-ok HTTP responses and network errors — logging the status/body to stderr — instead of throwing a BugzillaError.

Why

Only the four write handlers (createBug, updateBug, createComment, createAttachment) wrapped apiFetch in try/catch. The thirteen read/tag handlers called it bare, so any API error (404, 401, 500, network) escaped the tool boundary as an unhandled throw instead of a tidy Error: … message to the MCP client.

Every handler was already written for the fail-soft contract (const data = await apiFetch(...); return data ? ok(...) : err(...)), so the correct fix is to make apiFetch honour that contract rather than sprinkle thirteen more try/catch blocks.

Changes

  • apiFetch returns null on error (logs detail to stderr); the unused BugzillaError class is removed.
  • The four now-redundant inline try/catch blocks are removed — every handler is uniform: fetch → null-check → ok/err.
  • New .github/workflows/ci.yml running typecheck + build + test on PRs and pushes to main.

Verification

npm run typecheck clean; npm test42/42 pass (the 20 previously-failing error-path tests now pass against the fixed contract).

Move try/catch from individual callers into apiFetch, which now returns null on any HTTP or network error and logs via console.error. Removes BugzillaError class. Callers (createBug, updateBug, createComment, createAttachment) are simplified to null-check the return value. Adds CI workflow running typecheck, build, and test on push/PR to main.
@kud
kud marked this pull request as ready for review July 5, 2026 01:38
@kud
kud merged commit 2d36faf into main Jul 5, 2026
1 check passed
@kud
kud deleted the fix/apifetch-error-handling-and-ci branch July 5, 2026 01:38
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.

1 participant