← Back to PRs

#22720: fix: notify sessions on invalid config during hot-reload

by jayleekr open 2026-02-21 15:19 View on GitHub →
gateway size: S
## Summary - Config hot-reload (`config-reload.ts:299`) silently drops invalid configs with only a `warn()` log — no notification reaches active sessions or channels - Added an optional `onInvalidConfig` callback to `startGatewayConfigReloader` that fires with the list of validation issues - The gateway server wires this to broadcast a `config.invalid` event to all connected sessions, so users/agents get immediate feedback when config is broken ## Impact When an agent or user edits config incorrectly, they now get notified immediately instead of discovering the issue only after a gateway restart causes downtime. ## Files changed - `src/gateway/config-reload.ts` — Added `onInvalidConfig` optional callback to opts, invoke it on invalid snapshot - `src/gateway/server.impl.ts` — Wire `onInvalidConfig` to `broadcast("config.invalid", ...)` - `src/gateway/config-reload.test.ts` — Added test for `startGatewayConfigReloader` with `onInvalidConfig` ## Test plan - [x] Existing tests pass: `pnpm vitest run src/gateway/config-reload.test.ts` (9/9 passed) - [x] Build passes: `pnpm build` - [ ] E2E: Corrupt config while gateway running → verify session receives `config.invalid` event 🤖 Generated with [Claude Code](https://claude.com/claude-code) AI was used to generate this PR. Code has been reviewed and lightly tested locally. <!-- greptile_comment --> <h3>Greptile Summary</h3> Added `onInvalidConfig` callback to config hot-reload system that broadcasts `config.invalid` events to all connected sessions when validation fails during reload, giving users immediate feedback instead of silent failure. Changes: - `src/gateway/config-reload.ts`: Added optional `onInvalidConfig` callback parameter, invokes it with validation issues array when config snapshot is invalid - `src/gateway/server.impl.ts`: Wires callback to broadcast `config.invalid` event with `dropIfSlow: true` - `src/gateway/config-reload.test.ts`: Added test verifying callback signature is accepted (type-level check only, not functional test) The implementation correctly uses optional chaining (`?.`) and follows the existing broadcast pattern used for other events like `voicewake.changed` and `heartbeat`. <h3>Confidence Score: 4/5</h3> - Safe to merge with one test improvement suggestion - Clean implementation following existing patterns. Optional callback correctly uses `?.` operator, broadcast signature matches other events, early return preserves control flow. Test is weak (type-check only) but PR description notes E2E testing needed. No logical errors or runtime issues. - No files require special attention <sub>Last reviewed commit: 4899f1c</sub> <!-- greptile_other_comments_section --> <sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs