Repository navigation
Cover pflag parsing and make test flag restoration slice-safe - #16950
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Temporary slice overrides leave pflag’s private first-set state altered after cleanup, causing subsequent Set calls to append to restored defaults rather than replace them.
1 open issue
What changed in this PR
This PR strengthens CLI regression coverage and improves temporary flag restoration in test helpers, addressing the pflag review in #16909 without changing the dependency version.
Changes:
- Adds parsing tests for shorthand values, missing arguments, and grouped or repeated verbosity flags.
- Uses cloned slice snapshots and
Replace()for cleanup, registering cleanup before overrides. - Adds restoration coverage for slice contents, scalar values,
Changedbits, and snapshot isolation.
| File | Description |
|---|---|
internal/cmd/run_test.go |
Updates flag restoration and adds helper regression tests. |
internal/cmd/flags_test.go |
Adds shorthand and verbosity parsing tests. |
Review effort: Balanced (adaptive)
| if slice, ok := s.flag.Value.(pflag.SliceValue); ok { | ||
| assert.NoError(t, slice.Replace(s.slice)) |
This comment has been minimized.
This comment has been minimized.
|
@copilot address review feedback |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE No write succeeded or leaked on any surface. Part B is INCONCLUSIVE because the backend GitHub MCP server runs with
|

CLI tests checked flag metadata without exercising shorthand or verbosity parsing. The flag override helper also corrupted slice values by restoring them through
String()/Set().=values for-l/-c, missing values, and grouped/repeated verbosity flags.SliceValue.GetSlice()snapshots and restore withReplace(), preserving contents andChangedbits. Register cleanup before applying overrides.pflag remains pinned to v1.1.0.