Skip to content

fix: migrate all 10 filepath.Walk err-shadow sites (ADR-49633) and enforce in CI - #49907

Merged
pelikhan merged 5 commits into
mainfrom
copilot/adr-49633-migrate-walkfuncerrshadow
Aug 3, 2026
Merged

pelikhan merged 5 commits into
mainfrom
copilot/adr-49633-migrate-walkfuncerrshadow

Conversation

Copilot AI commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Ten filepath.Walk call sites used err for both the outer walk result and the callback's third parameter, silently shadowing the outer variable. This is the one-time migration cost called out in ADR-49633; the linter existed but was never enforced and the migration was never done.

Changes

  • Rename outer err → walkErr at all 10 flagged sites across 6 files, matching the convention already used at other Walk call sites in the codebase (logs_utils.go, copilot_agent.go, logs_metrics.go:985):
// Before — callback err silently shadows outer err
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { ... })
if err != nil { ... }

// After
walkErr := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { ... })
if walkErr != nil { ... }
  • pkg/cli/logs_download.go — 2 sites (flattenArtifactTree, listArtifacts)

  • pkg/cli/compile_watch.go — 1 site (subdirectory watcher setup)

  • pkg/cli/trial_support.go — 1 site (artifact directory walk)

  • pkg/cli/remove_command.go — 3 sites (cleanupOrphanedIncludes, getAllIncludeFiles, cleanupAllIncludes)

  • pkg/cli/logs_metrics.go — 2 sites (log file walk, MCP failure extraction)

  • pkg/cli/dependency_graph.go — 1 site (BuildGraph)

  • .github/workflows/cgo.yml — adds -walkfuncerrshadow to both LINTER_FLAGS invocations (native and wasm) so the pattern is caught in CI going forward.

  • ADR-49633 — status flipped from Draft → Accepted.


run: https://github.com/github/gh-aw/actions/runs/30811225763

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 5.44 AIC · ⌖ 5.36 AIC · ⊞ 8.3K · ◷
Comment /souschef to run again

… (ADR-49633 migration)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix err shadowing in production sites for walkfuncerrshadow fix: migrate all 10 filepath.Walk err-shadow sites (ADR-49633) and enforce in CI Aug 3, 2026
Copilot AI requested a review from pelikhan August 3, 2026 06:41
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Triage Result

Category: refactor | Risk: medium | Score: 52/100 (impact 25, urgency 12, quality 15)

Recommended action: defer

Draft PR, CI pending, moderate-size refactor across 8 files (filepath.Walk err-shadow migration). No reviews yet. Revisit once CI completes and draft is marked ready.

Generated by 🔧 PR Triage Agent · auto · 27.4 AIC · ⌖ 2.42 AIC · ⊞ 8K · ◷

@pelikhan
pelikhan marked this pull request as ready for review August 3, 2026 11:13
Copilot AI review requested due to automatic review settings August 3, 2026 11:13
@github-actions

github-actions Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

❌ Test Quality Sentinel failed during test quality analysis.

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.

Pull request overview

Migrates all ten filepath.Walk shadowing sites and enables ongoing CI enforcement.

Changes:

  • Renames outer walk errors to walkErr across six Go files.
  • Enables walkfuncerrshadow for native and WASM lint jobs.
  • Marks ADR-49633 as accepted.
Show a summary per file
File Description
pkg/cli/trial_support.go Renames artifact walk error.
pkg/cli/remove_command.go Renames three include-walk errors.
pkg/cli/logs_metrics.go Renames two log-walk errors.
pkg/cli/logs_download.go Renames two artifact-walk errors.
pkg/cli/dependency_graph.go Renames workflow scan error.
pkg/cli/compile_watch.go Renames watcher setup walk error.
.github/workflows/cgo.yml Enforces the linter in CI.
docs/adr/49633-add-walkfuncerrshadow-linter-for-filepath-walk-err-shadow.md Accepts the ADR.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 8/8 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

github-actions Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #49907 does not have the implementation label and has only 28 new lines in business logic directories (threshold: 100).

@github-actions github-actions Bot 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.

Skills-Based Review 🧠

Applied /diagnosing-bugs — clean, mechanical migration with no logic changes.

📋 Review Summary

What was done

  • All 10 filepath.Walk err-shadow sites renamed err → walkErr consistently
  • Linter flag -walkfuncerrshadow added to both native and wasm CI invocations
  • ADR-49633 status updated to Accepted

Positive Highlights

  • ✅ Every renamed site uses walkErr — matches existing convention
  • ✅ CI enforcement added in the same PR, preventing regression
  • ✅ Wasm linter invocation also picks up the flag (no coverage gap)
  • ✅ Pure rename — no behaviour changes, low risk

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 17.1 AIC · ⌖ 8.08 AIC · ⊞ 7.1K
Comment /matt to run again

@github-actions github-actions Bot 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.

The changes are a clean, mechanical rename of err → walkErr at all 10 filepath.Walk call sites across 6 files. The fix is correct, consistent, and complete.

One minor observation: -walkfuncerrshadow is also added to the wasm linter step, but that step's LINTER_PACKAGES only covers ./pkg/console ./pkg/parser ./pkg/styles ./pkg/tty ./pkg/workflow — none of the changed packages — so the flag is effectively a no-op there. Harmless; the native linter step is the one that actually enforces this across ./pkg/cli.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 16.7 AIC · ⌖ 7.58 AIC · ⊞ 5.4K

@github-actions github-actions Bot 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.

Verdict: Approve — clean, mechanical fix

All 10 filepath.Walk sites correctly rename the outer err to walkErr, eliminating the shadow bug. Verified each site: no leftover references to the old err name, no scoping conflicts (e.g. remove_command.go inner err := in the loop is unaffected since it's a different, inner scope). CI linter flag and ADR status update are consistent with the stated migration. Build succeeds.

Notes

No blocking issues found. Confirmed via go build ./pkg/cli/... that the package compiles cleanly after the renames.

🔎 Code quality review by PR Code Quality Reviewer · auto · 13.3 AIC · ⌖ 3.77 AIC · ⊞ 7.9K
Comment /review to run again

This was referenced Aug 3, 2026
@pelikhan

pelikhan commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main and recompile

Copilot AI and others added 2 commits August 3, 2026 11:37
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…rate-walkfuncerrshadow

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge main and recompile

Done — merged main and recompiled all 269 workflows (all in sync, zero errors).

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please take the next maintainer-ready step on this PR. Refresh the branch if GitHub allows it, verify checks, and run the pr-finisher skill before handing back.

Run: https://github.com/github/gh-aw/actions/runs/30811225763

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 5.44 AIC · ⌖ 5.36 AIC · ⊞ 8.3K · ◷
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please take the next maintainer-ready step on this PR. Refresh the branch if GitHub allows it, verify checks, and run the pr-finisher skill before handing back.

Run: https://github.com/git...

Done. Here's the PR finisher summary:

  • ✅ Reviews — No unresolved review threads.
  • ✅ Checks (local) — make fmt, make lint, make test-unit, make recompile all pass. Root cause of the CI failure fixed: pkg/cli/data/agentic_workflows_fallback_aw_files.json was missing token-optimization-observability.md (added via main merge); committed in 6f90fab.
  • ❓ Checks (CI) — Stale after agent push; needs human re-trigger. Prior failure (Unit tests (D-L) / TestFallbackAWFilesMatchesLocalAWDirectory) fixed at the root cause and verified locally.
  • ✅ Mergeable — PR is open, not draft, no conflicts.

Actions taken: Fixed TestFallbackAWFilesMatchesLocalAWDirectory by adding the missing token-optimization-observability.md entry to the fallback aw files list.

Hand-off: CI must be re-triggered by a maintainer (close/reopen PR, workflow_dispatch, or push) before merge.

Copilot AI requested a review from gh-aw-bot August 3, 2026 12:12
@pelikhan
pelikhan merged commit 144da85 into main Aug 3, 2026
29 checks passed
@pelikhan
pelikhan deleted the copilot/adr-49633-migrate-walkfuncerrshadow branch August 3, 2026 12:45
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.84.4

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

walkfuncerrshadow (61st linter): 10 production sites still shadow err/err — migration from ADR-49633 not done

4 participants