Harden Cobra command behavior: graceful proxy shutdown, default consistency, and completion updates#7047
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Review Go Module spf13/cobra for compliance
Harden Cobra command behavior: graceful proxy shutdown, default consistency, and completion updates
Jun 5, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the awmg Cobra CLI by making proxy shutdown behavior graceful, aligning proxy --guards-mode defaults with the root command/environment-driven behavior, and modernizing shell completion generation and flag filename completion metadata.
Changes:
- Implement graceful HTTP server shutdown for
awmg proxyusinghttp.Server.Shutdownwith a bounded timeout and error propagation. - Align
proxy --guards-modedefault todifc.DefaultEnforcementMode()and extend tests to cover env-driven defaults. - Modernize Bash completion generation (
GenBashCompletionV2) and replace manual file-extension completion callbacks withMarkFlagFilename+ updated completion tests.
Show a summary per file
| File | Description |
|---|---|
| internal/cmd/root.go | Removes -v info-level startup log noise while keeping higher verbosity/debug logging behavior. |
| internal/cmd/root_test.go | Adds a regression test asserting -v doesn’t emit startup log output. |
| internal/cmd/proxy.go | Adds graceful proxy HTTP drain on shutdown and aligns --guards-mode default with difc.DefaultEnforcementMode(). |
| internal/cmd/proxy_test.go | Updates defaults test and adds env-driven default coverage for --guards-mode. |
| internal/cmd/flags.go | Switches config/env completions to MarkFlagFilename(...) with error handling. |
| internal/cmd/flags_test.go | Updates tests to assert Cobra filename-extension annotations instead of custom completion funcs. |
| internal/cmd/completion.go | Switches Bash completion generation to GenBashCompletionV2(..., true) for richer metadata. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 7/7 changed files
- Comments generated: 0
This was referenced Jun 5, 2026
Closed
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.
This issue identified several Cobra integration gaps in
awmg: proxy shutdown was abrupt,proxy --guards-modeused a divergent default, Bash completion was on the legacy generator, and CLI completion/verbosity behavior had minor UX inconsistencies. This PR aligns proxy/root command behavior and modernizes completion wiring with minimal surface-area changes.Proxy shutdown semantics
proxynow performs graceful HTTP drain on exit (Shutdown+ timeout) instead of immediate connection teardown (Close).guards-modedefault alignmentproxy --guards-modenow usesdifc.DefaultEnforcementMode()instead of a hardcoded literal, matching root command behavior and env-driven defaults.Shell completion modernization
GenBashCompletionV2(..., true)to include richer completion metadata.--configand--envwithMarkFlagFilename(...)and explicit error handling.Verbosity UX cleanup
-v(level 1) informational startup log line that added noise without changing runtime logging behavior.Targeted test adjustments
guards-modedefault behavior.MarkFlagFilenameannotations forconfig/env.-vdoes not emit extra startup noise.