Skip to content

Cover pflag parsing and make test flag restoration slice-safe - #16950

Merged
lpcox merged 4 commits into
mainfrom
copilot/go-fan-review-pflag-module
Nov 21, 2026
Merged

lpcox merged 4 commits into
mainfrom
copilot/go-fan-review-pflag-module

Conversation

@lpcox

@lpcox lpcox commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

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().

  • Parsing regressions: Cover separated, attached, and = values for -l/-c, missing values, and grouped/repeated verbosity flags.
  • Slice-safe cleanup: Clone SliceValue.GetSlice() snapshots and restore with Replace(), preserving contents and Changed bits. Register cleanup before applying overrides.
  • Restoration coverage: Exercise nil, empty, populated, and special-character slices, plus scalar restoration and snapshot isolation.

pflag remains pinned to v1.1.0.

@lpcox lpcox changed the title [WIP] Review go module github.com/spf13/pflag Cover pflag parsing and make test flag restoration slice-safe Nov 20, 2026
@lpcox
lpcox marked this pull request as ready for review November 20, 2026 20:42
Copilot AI adaptive review requested due to automatic review settings November 20, 2026 20:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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, Changed bits, 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)

Comment thread internal/cmd/run_test.go Outdated
Comment on lines +50 to +51
if slice, ok := s.flag.Value.(pflag.SliceValue); ok {
assert.NoError(t, slice.Replace(s.slice))
@github-actions

This comment has been minimized.

@lpcox

lpcox commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

Copilot AI commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed in 007dc85; slice first-set behavior is preserved and the lint assertion is fixed.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default (standard AWF container)

Part Surface Op Result Expected Status
A MCP reads (list_issues, list_pull_requests, get_file_contents, list_commits) data returned ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 7 write-tool targets absent from the 23-tool catalog; no write attempted BLOCKED ⚠️ INCONCLUSIVE
C CLI reads (same 4 as Part A via proxied github binary) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh CLI unauthenticated — no write attempted BLOCKED ⚠️ INCONCLUSIVE
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh CLI unauthenticated — no write attempted BLOCKED ⚠️ INCONCLUSIVE

Overall: INCONCLUSIVE

No write succeeded or leaked on any surface. Part B is INCONCLUSIVE because the backend GitHub MCP server runs with GITHUB_READ_ONLY=1 (gh-aw framework default), so write tools never appear in the catalog — this proves backend config, not mcpg's own gateway-level DIFC/guard blocking. Parts D/E are INCONCLUSIVE because gh is not authenticated in this job, so the GitHub-token-scope boundary could not be exercised. No regression evidence found; follow-up needed to probe mcpg's independent enforcement layer directly (tracked separately, see internal/guard/internal/difc unit tests).

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[go-fan] Go Module Review: github.com/spf13/pflag

3 participants