Fix nil-request panic, startup log, and metric naming#19
Merged
Conversation
- Guard against nil AdmissionReview.Request to prevent server panic on malformed bodies; return 400 instead - Log the actual configured port instead of hardcoded :8443 - Rename request duration metric to _seconds and fix help text to match the seconds value actually recorded - Fix "frequet" typo in README - Add test covering the nil-request path Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Fixes several correctness and consistency issues found in the webhook.
main.gorequestfield leavesAdmissionReview.Requestnil; accessing.UIDcrashes the serverRequest, return400 Bad Requestmain.go:8443, ignoring the--portflagaddrmain.go.Seconds()..._request_duration_secondsand fix help textREADME.mdAdded
TestHandleAdmissionReview_NilRequestto lock in the panic fix.Item 3 renames the Prometheus metric from
grafana_operator_webhook_request_durationtografana_operator_webhook_request_duration_secondsto follow Prometheus naming conventions. Any existing Grafana dashboards or alerts referencing the old name must be updated.Test plan
go build ./...go vet ./...go test ./...(all pass, including new test)🤖 Generated with Claude Code