feat(doctor): hook-config validation in /doctor#227
Merged
emal-avala merged 1 commit intomainfrom Apr 23, 2026
Merged
Conversation
A misconfigured hook silently does nothing at runtime — a shell hook with an empty command string fails its subprocess, and an HTTP hook with a malformed URL fails its request. Users only notice when the expected side-effect (audit log, Slack ping, backup) doesn't happen. /doctor is the right place to surface these early, before they become production-debugging ghost stories. Adds a hooks:* section to the /doctor output that: - Skips entirely when no hooks are configured (no noise) - Emits one hooks:count Pass line when all hooks are valid - Emits one hooks:entry:<i> Fail per broken entry: - Shell action with empty (or whitespace-only) command - HTTP action with a URL that reqwest::Url can't parse - Emits one hooks:entry:<i> Warn per HTTP action with a method string that isn't one of GET/POST/PUT/PATCH/DELETE — those get silently treated as POST by the dispatcher, which is almost certainly not what the user wrote Ships with a new private is_valid_http_method helper that matches the exact verb set the dispatcher actually recognizes. 7 new tests: - is_valid_http_method accepts common verbs (case-insensitive) - is_valid_http_method rejects typos (GETS, HEAD, empty, POSTT) - No hooks configured -> no hooks:* checks emitted - N valid hooks -> single hooks:count Pass - Empty shell command -> Fail entry + Fail count - Malformed URL -> Fail entry - Unknown HTTP method -> Warn entry
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A misconfigured hook silently does nothing at runtime — a shell hook with an empty command string fails its subprocess; an HTTP hook with a malformed URL fails its request. Users only notice when the expected side-effect (audit log, Slack ping, backup) doesn't happen.
/doctoris the right place to surface these early, before they become production-debugging ghost stories.Adds a
hooks:*section to the/doctoroutput that:hooks:countline when all hooks are validreqwest::Urlcan't parseShips with a new private
is_valid_http_methodhelper that matches the exact verb set the dispatcher actually recognizes.Example output
or when broken:
Test plan
cargo clippy --workspace --tests --no-deps -- -D warnings— cleancargo test -p agent-code-lib --lib services::diagnostics::tests— 16 pass (9 prior + 7 new)7 new tests:
is_valid_http_methodaccepts common verbs (case-insensitive)is_valid_http_methodrejects typos (GETS,HEAD, empty,POSTT)hooks:*checks emittedhooks:countPass