web: validate the flag configuration in Serve and ServeMultiple - #439
Open
mrueg wants to merge 1 commit into
Open
web: validate the flag configuration in Serve and ServeMultiple#439mrueg wants to merge 1 commit into
mrueg wants to merge 1 commit into
Conversation
ListenAndServe validates its FlagConfig before using it, but Serve and ServeMultiple went straight to dereferencing flags.WebConfigFile. Both are exported for callers that create their own listeners, and such a caller builds a FlagConfig by hand rather than getting one from kingpinflag, so passing one without WebConfigFile set is an easy mistake. It crashed the process with a nil pointer dereference instead of returning ErrMissingFlag. Check the flags in both, using a narrower check than checkFlags. The listener fields are deliberately not required here: the caller supplies the listener, so demanding a listen address or the systemd socket flag would reject a legitimate configuration. checkFlags keeps requiring them for ListenAndServe, which does create the listeners itself, and now shares the web config half of the validation. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Manuel Rüger <manuel@rueg.eu>
mrueg
force-pushed
the
fix/serve-nil-flag-config
branch
from
September 2, 2026 13:44
ad48efc to
a236bc9
Compare
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.
ListenAndServevalidates itsFlagConfigbefore using it, butServeandServeMultiplego straight to dereferencingflags.WebConfigFile.Both are exported for callers that create their own listeners, and such a caller builds a
FlagConfigby hand rather than getting one fromkingpinflag, so passing one withoutWebConfigFileset is an easy mistake. It crashes the process instead of returningErrMissingFlag:Change
Check the flags in both, using a narrower check than
checkFlags. The listener fields are deliberately not required here: the caller supplies the listener, so demanding a listen address or the systemd socket flag would reject a legitimate configuration.checkFlagskeeps requiring them forListenAndServe, which does create the listeners, and now shares the web-config half of the validation.🤖 Generated with Claude Code