Skip to content

Add errx-migrate: type-aware pkg/errors → errx migrator - #1

Merged
denisvmedia merged 4 commits into
masterfrom
feat/initial-migrator
May 30, 2026
Merged

denisvmedia merged 4 commits into
masterfrom
feat/initial-migrator

Conversation

@denisvmedia

@denisvmedia denisvmedia commented May 30, 2026 •

Copy link
Copy Markdown
Member

Implements go-extras/errx#44: a small, type-aware AST rewriter that converts a github.com/pkg/errors-based codebase to github.com/go-extras/errx, safely and idempotently.

What it does

  • cmd/errx-migrate CLI and a reusable go/analysis Analyzer (AnalyzerStack / AnalyzerLean) share one rewrite core via a small PkgView abstraction over *packages.Package / *analysis.Pass.
  • Two modes: stack-preserving (default, maps to the stacktrace subpackage) and lean (-no-stack, maps to the errx core + stdlib).
  • Type-aware via golang.org/x/tools/go/packages: resolves which errors identifier is really pkg/errors (aliases, dot-imports, shadowing) and never touches stdlib errors.
  • Safe & idempotent: arg order is swapped, fmt.Sprintf is injected for Wrapf/Errorf/WithMessagef, errors.Cause becomes an inline root-unwrap loop, and anything ambiguous is left untouched with a // TODO(errx-migrate) marker. Output is gofmt/goimports-clean; re-running is a no-op.

Mapping

pkg/errors stack-preserving lean (-no-stack)
New stacktrace.ClassifyNew errors.New
Errorf stacktrace.ClassifyNew(fmt.Sprintf(...)) fmt.Errorf
Wrap(err,msg) stacktrace.Wrap(msg,err) errx.Wrap(msg,err)
Wrapf stacktrace.Wrap(fmt.Sprintf(...),err) errx.Wrap(fmt.Sprintf(...),err)
WithMessage[f] errx.Wrap(...) errx.Wrap(...)
WithStack stacktrace.Classify stacktrace.Classify
Is/As/Unwrap stdlib errors.* same
Cause inline root-unwrap + TODO same

Flags

-w (write), -diff (unified diff), -no-stack (lean), -include-generated.

Tests

Golden tests for every mapping row in both modes (offline, against local stubs), a compile + idempotency check, an analysistest for the Analyzer, and a CLI end-to-end test. golangci-lint (go-extras config) is clean; go mod tidy is a no-op.

Real-world verification (kopia/kopia)

Ran against kopia/kopia (427 files, ~2,700 pkg/errors call sites): 365 files migrated in ~5s, go build ./... and go vet ./... both pass, gofmt-clean, idempotent on re-run, zero crashes/warnings. Remaining sites are correctly left with // TODO(errx-migrate) (a pkg/errors call nested inside a closure, %w in a format string) or are build-tagged for another GOOS (re-run per GOOS).

Notes

  • %+v stack rendering after migration depends on a companion fix in errx itself (the carrier needs to forward %+v to its captured trace) — filed separately.

Summary by CodeRabbit

  • New Features

    • Added errx-migrate CLI and analyzers to automate pkg/errors → go-extras/errx migration with stack-preserving and lean modes; supports diff, write, and stdout outputs.
  • Documentation

    • Expanded README with installation, usage, flags, behavior notes, API mapping, and limitations.
  • Tests

    • Added analyzer, end-to-end, and golden-suite tests with offline stubs to validate rewrites and idempotency.
  • Chores

    • Added CI, linting, and release workflows plus a Makefile and release packaging configuration.

Review Change Stack

Implements cmd/errx-migrate plus a reusable go/analysis Analyzer that
rewrites github.com/pkg/errors usage to github.com/go-extras/errx.

- Two modes: stack-preserving (default) and lean (-no-stack).
- Type-aware via golang.org/x/tools/go/packages: resolves aliases,
  dot-imports, and shadowing, and never rewrites stdlib errors.
- Safe and idempotent: argument order is swapped correctly, fmt.Sprintf
  is injected for Wrapf/Errorf/WithMessagef, errors.Cause becomes an
  inline root-unwrap loop, and anything ambiguous is left untouched with
  a // TODO(errx-migrate) marker. Output is gofmt/goimports-clean.
- Golden tests (both modes), a compile + idempotency check, an
  analysistest for the Analyzer, and a CLI end-to-end test.
- golangci-lint config, Makefile, CI workflows, and GoReleaser mirroring
  the go-extras tooling.

Implements go-extras/errx#44.
Copilot AI review requested due to automatic review settings May 30, 2026 13:39
@coderabbitai

coderabbitai Bot commented May 30, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 267d483b-012c-476d-94e2-fafa4fbfcf6e

📥 Commits

Reviewing files that changed from the base of the PR and between 93ed4e1 and 69de7ba.

📒 Files selected for processing (4)
  • .github/workflows/ci.yml
  • .github/workflows/go-lint.yml
  • .github/workflows/release.yml
  • Makefile
🚧 Files skipped from review as they are similar to previous changes (2)
  • Makefile
  • .github/workflows/go-lint.yml

📝 Walkthrough

Walkthrough

Adds errx-migrate: an AST- and type-aware migrator (library, CLI, and go/analysis analyzer) that rewrites usages of github.com/pkg/errors to github.com/go-extras/errx, plus import/comment/edit helpers, unified diff output, CI/lint/release infra, and extensive golden, stability, and analyzer tests.

Changes

Infrastructure and Configuration

Layer / File(s) Summary
Project Configuration and Documentation
go.mod, .golangci.yml, .goreleaser.yaml, Makefile, README.md
Go module and tooling deps; comprehensive golangci-lint config; GoReleaser configuration; Makefile targets; and expanded README documenting the tool, modes, flags, mappings, and development commands.
CI/CD Workflows
.github/workflows/ci.yml, .github/workflows/go-lint.yml, .github/workflows/release.yml
GitHub Actions workflows for CI (build/tests/coverage with threshold and Codecov), linting and govulncheck, and release snapshot/production builds via GoReleaser with artifact uploads.

Core Migration Engine

Layer / File(s) Summary
Mode configuration and call detection
mode.go, detect.go
Public Mode (ModeStack/ModeLean) and type-aware detection of recognized pkg/errors calls using go/ast + go/types.
PkgView and Analyzer integration
pkgview.go, analyzer.go, analyzer_test.go, testdata/analyzer/*
PkgView adapters for analysis/packages inputs; NewAnalyzer factory and exported analyzers (AnalyzerStack, AnalyzerLean) with tests exercising the analyzer against fixtures.
Rewrite pipeline and builders
rewrite.go, build_edits.go
AST rewrite pipeline that collects outermost matches, builds mode-specific replacements or guarded TODOs, aggregates import edits, and emits diagnostics with suggested fixes; per-function rewrite builders (New/Errorf/Wrap/Wrapf/WithMessage/WithStack/Cause/Is/As/Unwrap).
Import, comments, and edit application
imports.go, comments.go, apply.go
Helpers to add/remove imports safely, detect/preserve inline comments and insert idempotent TODO markers, and apply grouped text edits using token.FileSet offsets while validating and rejecting overlapping edits.

Command-Line Tool and Output

Layer / File(s) Summary
CLI entry point
cmd/errx-migrate/main.go, cmd/errx-migrate/main_test.go
Command-line program: flags (mode, diff/write, include-generated), package loading (with type/syntax), rewrite invocation, edit deduplication across package variants, and file emission or unified-diff output; includes an end-to-end CLI test.
Unified diff output
cmd/errx-migrate/diff.go
LCS-based unified-diff generator with hunk grouping and formatted headers for --diff output.

Testing and Fixtures

Layer / File(s) Summary
Analyzer tests
analyzer_test.go, testdata/analyzer/*
Validation of analyzer construction and an analysistest run against analyzer fixtures.
Golden tests and runner
golden_test.go, testdata/src/*, testdata/go.mod
Golden-file test harness that runs rewrite in stack/lean modes, applies edits, formats output, and compares or updates golden files with -update.
Stability and E2E tests
stable_test.go, cmd/errx-migrate/main_test.go
Stability/idempotence tests assembling temporary modules from goldens and an end-to-end CLI test that runs the tool against a temp module with local stubs.
Test stubs and fixtures
testdata/stub/*, testdata/src/*
Offline stubs for github.com/pkg/errors and github.com/go-extras/errx plus 20+ fixture packages exercising aliasing, dot-imports, shadowing, comments, dynamic messages, %w cases, multi-import scenarios, and other edge cases.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Poem

🐰 Hop hop, the errors now flow,
From pkg/errors to errx we go,
AST hops through code with care,
Golden tests show rewrites fair,
CI hums while binaries grow!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/initial-migrator

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 12

🧹 Nitpick comments (4)
.github/workflows/go-lint.yml (1)

44-44: ⚡ Quick win

Pin govulncheck to a specific version instead of @latest.

At Line 44, @latest makes CI behavior drift over time. Pin to an explicit version for reproducible lint/security runs.

Suggested fix
-          go install golang.org/x/vuln/cmd/govulncheck@latest
+          go install golang.org/x/vuln/cmd/govulncheck@<pinned-version>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/go-lint.yml at line 44, Replace the floating install of
govulncheck by pinning the version: locate the line that runs "go install
golang.org/x/vuln/cmd/govulncheck@latest" and change the `@latest` suffix to an
explicit release tag (for example `@v0.9.0` or whatever current stable tag you
choose) so CI runs a reproducible, fixed version; update the pinned tag when you
intentionally bump the tool version.
apply.go (1)

38-50: ⚖️ Poor tradeoff

Consider pre-allocating output buffer for better performance.

The current implementation allocates a new byte slice for each edit. For files with many edits, this could be optimized by pre-calculating the final size or using bytes.Buffer. However, this is a minor optimization given typical usage patterns.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apply.go` around lines 38 - 50, The loop that builds the patched output
(variables out, prevStart, resolved and fields e.start/e.end/e.text) currently
allocates a new byte slice per edit; instead compute the final output length by
summing len(src) minus total removed bytes plus total inserted bytes, allocate a
single []byte of that capacity and then sequentially copy slices and e.text into
it (or use a single bytes.Buffer with Grow(finalLen)), updating write offsets as
you go to avoid per-edit reallocation and the repeated make/append pattern.
rewrite.go (1)

40-48: 💤 Low value

Silent error suppression when reading source.

If view.Source(file) fails, rewriteFile silently returns nil, hiding the error. Consider logging or propagating this error so users know when files are skipped due to read failures.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rewrite.go` around lines 40 - 48, rewriteFile currently swallows errors from
view.Source(file); instead of returning nil, create and return a descriptive
analysis.Diagnostic when view.Source(file) returns an error: construct a
diagnostic that includes err.Error() in the Message, set the Pos (or Start/End)
to file.Pos() (or the file token range) and an appropriate Category/Severity so
callers see the failure; update the early-return branch in rewriteFile (the
view.Source(file) error handling) to return that diagnostic (or if project
conventions prefer, change rewriteFile to return ([]analysis.Diagnostic, error)
and propagate the error) and ensure callers handle the new return form if you
choose propagation.
analyzer_test.go (1)

21-27: ⚡ Quick win

Add a lean analyzer integration test.

Only stack mode is executed via analysistest.Run (Line 26). Add the same wiring test for AnalyzerLean to cover both analyzer front-ends.

Proposed patch
 func TestAnalyzerStack(t *testing.T) {
 	dir, err := filepath.Abs(filepath.Join("testdata", "analyzer"))
 	if err != nil {
 		t.Fatal(err)
 	}
 	analysistest.Run(t, dir, errxmigrate.AnalyzerStack, "example")
 }
+
+func TestAnalyzerLean(t *testing.T) {
+	dir, err := filepath.Abs(filepath.Join("testdata", "analyzer"))
+	if err != nil {
+		t.Fatal(err)
+	}
+	analysistest.Run(t, dir, errxmigrate.AnalyzerLean, "example")
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@analyzer_test.go` around lines 21 - 27, The test only runs the stack-mode
analyzer; add a parallel call to run the lean-mode analyzer by extending
TestAnalyzerStack (or creating a new TestAnalyzerLean) to invoke
analysistest.Run with errxmigrate.AnalyzerLean and the same "example"
package/dir; ensure you resolve dir and err the same way and call
analysistest.Run(t, dir, errxmigrate.AnalyzerLean, "example") so both
AnalyzerStack and AnalyzerLean are exercised.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Line 23: The CI workflow uses mutable action tags; replace each mutable tag
(e.g. actions/checkout@v6, actions/setup-go@v6, codecov/codecov-action@v6,
actions/upload-artifact@v7) with their corresponding pinned commit SHAs and add
"with: persist-credentials: false" to every checkout step (the actions/checkout
usage) to avoid token exposure; update the workflow entries where
actions/checkout is used to include the persist-credentials: false key and
change all other uses to the exact commit SHA instead of the `@vN` tag.

In @.github/workflows/go-lint.yml:
- Line 20: The workflow uses mutable action tags and leaves checkout credentials
enabled: replace uses: actions/checkout@v6, uses: actions/setup-go@v6, and uses:
golangci/golangci-lint-action@v9 with their respective pinned commit SHAs, and
add persist-credentials: false to the actions/checkout step to harden token
exposure; also replace the mutable go install .../govulncheck@latest invocation
with a pinned version (specific tag or version) so the installed tool is
immutable. Ensure you update the three uses entries and the govulncheck install
command and verify the exact commit SHAs/tags you pin.

In @.github/workflows/release.yml:
- Line 21: Update the workflow actions to use immutable commit SHAs and harden
checkout credentials: replace action tags actions/checkout@v6,
actions/setup-go@v6, goreleaser/goreleaser-action@v7, and
actions/upload-artifact@v7 with their corresponding full commit SHAs, and in the
actions/checkout step add with: persist-credentials: false (unless a later job
requires pushing with repo credentials) so the checkout does not expose tokens;
ensure you update the action refs for the steps that reference those identifiers
accordingly.
- Around line 11-14: The workflow currently sets broad workflow-level
permissions (permissions: contents: write, packages: write) and shares
actions/setup-go caching (cache: true with dependency path go.sum) across both
PR snapshot and tag release paths, exposing PR runs to unnecessary privileges
and shared cache; split the logic into two separate jobs (e.g., a "pr-snapshot"
job gated by if: github.event_name == 'pull_request' and a "tag-release" job for
tags), move minimal required permissions into each job (remove or tighten the
top-level permissions and set job-level permissions like contents: read for PR
and contents/packages: write only for tag-release), and configure
actions/setup-go cache keys so PR-snapshot uses an isolated PR-only cache key
(include github.event_number or pull_request id) while tag-release uses its own
cache key (e.g., based on ref), ensuring caching and permissions are scoped to
each job.

In `@cmd/errx-migrate/main.go`:
- Line 169: The inline nolint directive attached to the os.WriteFile call
(os.WriteFile(name, formatted, 0o600)) is unused and causing nolintlint
failures; remove the trailing //nolint:gosec comment on that line so the linter
no longer reports an invalid suppression, keeping the rest of the call unchanged
(use the existing variables name and formatted and the 0o600 permission).
- Around line 173-175: The stdout write in the default output path currently
ignores errors (os.Stdout.Write(formatted)), so detect and handle the returned
(n, err) and fail the command on error; after printing the header
(fmt.Print(header)) check the write result from os.Stdout.Write(formatted),
surface the error (return it, log it, or call os.Exit(1) as the surrounding
function requires) so broken/closed stdout causes the process to exit non‑zero
instead of appearing successful.

In `@golden_test.go`:
- Line 76: Remove the stale nolint:gosec suppression on the os.WriteFile call:
in the line calling os.WriteFile(goldenPath, formatted, 0o600) (references:
function os.WriteFile, variables goldenPath and formatted), delete the trailing
"//nolint:gosec" comment so the linter no longer reports an unused suppression.

In `@imports.go`:
- Around line 94-113: The code currently uses decl := firstImportDecl(file) then
later removes decl even when target (the matching *ast.ImportSpec) belongs to a
different import block; fix by finding the actual owning *ast.GenDecl for target
instead of reusing decl: iterate file.Decls (or import declarations) to locate
the GenDecl whose Specs contains target, assign it to a variable like
owningDecl, and then use owningDecl (not decl) when deciding whether to remove
the whole declaration (calling wholeLinesEdit(tf, owningDecl.Pos(),
owningDecl.End())) or to remove only the target import (wholeLinesEdit(tf,
target.Pos(), target.End())); keep existing logic for paren/singleton checks but
reference owningDecl when checking Lparen and Specs length.

In `@Makefile`:
- Line 1: The Makefile currently lists .PHONY first which can cause all phony
prerequisites (build, install, test, lint, lint-fix, fmt, clean, help) to run on
a bare `make`; add an explicit default goal by setting .DEFAULT_GOAL (e.g.,
`.DEFAULT_GOAL := help`) near the top of the file so `make` runs only the
intended default target instead of all .PHONY prerequisites, keeping the
existing .PHONY declaration intact and referencing the `help` target as the
default.

In `@stable_test.go`:
- Line 107: The test contains an unused gosec suppression on the os.WriteFile
call (the expression os.WriteFile(filepath.Join(dir, pkgDir, "p.go"), data,
0o600) //nolint:gosec); remove the trailing "//nolint:gosec" from that line in
stable_test.go so the linter no longer reports an unused suppression while
leaving the rest of the call unchanged.

In `@testdata/src/nested/in.lean.golden`:
- Around line 3-8: The golden fixture imports the external package
"github.com/go-extras/errx/stacktrace" and calls stacktrace.Classify(err), which
violates the -no-stack contract; remove the stacktrace import from the import
block and update the call site in function N to use the core API instead
(replace stacktrace.Classify(err) with errx.Classify(err) or plain err if
Classify is not available in core) so the file only depends on
"github.com/go-extras/errx".

In `@testdata/src/withstack/in.lean.golden`:
- Around line 3-7: The golden fixture currently asserts stack-mode output
because S uses stacktrace.Classify(err) and the file only contains the
stack-mode result; update the test fixture so it also validates the -no-stack
mapping: either replace or extend the content in the testdata with a variant
that exercises the no-stack mapping (e.g. remove or avoid calling
stacktrace.Classify in a separate case) or add a second golden case for the same
symbol S that expects the -no-stack output; locate the usage of
stacktrace.Classify in function S and ensure the fixture contains both
stack-mode and no-stack-mode expectations so regressions in lean mapping are
detected.

---

Nitpick comments:
In @.github/workflows/go-lint.yml:
- Line 44: Replace the floating install of govulncheck by pinning the version:
locate the line that runs "go install golang.org/x/vuln/cmd/govulncheck@latest"
and change the `@latest` suffix to an explicit release tag (for example `@v0.9.0` or
whatever current stable tag you choose) so CI runs a reproducible, fixed
version; update the pinned tag when you intentionally bump the tool version.

In `@analyzer_test.go`:
- Around line 21-27: The test only runs the stack-mode analyzer; add a parallel
call to run the lean-mode analyzer by extending TestAnalyzerStack (or creating a
new TestAnalyzerLean) to invoke analysistest.Run with errxmigrate.AnalyzerLean
and the same "example" package/dir; ensure you resolve dir and err the same way
and call analysistest.Run(t, dir, errxmigrate.AnalyzerLean, "example") so both
AnalyzerStack and AnalyzerLean are exercised.

In `@apply.go`:
- Around line 38-50: The loop that builds the patched output (variables out,
prevStart, resolved and fields e.start/e.end/e.text) currently allocates a new
byte slice per edit; instead compute the final output length by summing len(src)
minus total removed bytes plus total inserted bytes, allocate a single []byte of
that capacity and then sequentially copy slices and e.text into it (or use a
single bytes.Buffer with Grow(finalLen)), updating write offsets as you go to
avoid per-edit reallocation and the repeated make/append pattern.

In `@rewrite.go`:
- Around line 40-48: rewriteFile currently swallows errors from
view.Source(file); instead of returning nil, create and return a descriptive
analysis.Diagnostic when view.Source(file) returns an error: construct a
diagnostic that includes err.Error() in the Message, set the Pos (or Start/End)
to file.Pos() (or the file token range) and an appropriate Category/Severity so
callers see the failure; update the early-return branch in rewriteFile (the
view.Source(file) error handling) to return that diagnostic (or if project
conventions prefer, change rewriteFile to return ([]analysis.Diagnostic, error)
and propagate the error) and ensure callers handle the new return form if you
choose propagation.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 77a0c122-e3a6-4eda-b589-bcc84146b39f

📥 Commits

Reviewing files that changed from the base of the PR and between cb2e336 and 1f65625.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (76)
  • .github/workflows/ci.yml
  • .github/workflows/go-lint.yml
  • .github/workflows/release.yml
  • .golangci.yml
  • .goreleaser.yaml
  • Makefile
  • README.md
  • analyzer.go
  • analyzer_test.go
  • apply.go
  • build_edits.go
  • cmd/errx-migrate/diff.go
  • cmd/errx-migrate/main.go
  • cmd/errx-migrate/main_test.go
  • comments.go
  • detect.go
  • go.mod
  • golden_test.go
  • imports.go
  • mode.go
  • pkgview.go
  • rewrite.go
  • stable_test.go
  • testdata/analyzer/src/example/example.go
  • testdata/analyzer/src/github.com/pkg/errors/errors.go
  • testdata/go.mod
  • testdata/src/aliased/in.go
  • testdata/src/aliased/in.lean.golden
  • testdata/src/aliased/in.stack.golden
  • testdata/src/cause/in.go
  • testdata/src/cause/in.lean.golden
  • testdata/src/cause/in.stack.golden
  • testdata/src/comment/in.go
  • testdata/src/comment/in.lean.golden
  • testdata/src/comment/in.stack.golden
  • testdata/src/dotimport/in.go
  • testdata/src/dotimport/in.lean.golden
  • testdata/src/dotimport/in.stack.golden
  • testdata/src/errorf/in.go
  • testdata/src/errorf/in.lean.golden
  • testdata/src/errorf/in.stack.golden
  • testdata/src/isasunwrap/in.go
  • testdata/src/isasunwrap/in.lean.golden
  • testdata/src/isasunwrap/in.stack.golden
  • testdata/src/nested/in.go
  • testdata/src/nested/in.lean.golden
  • testdata/src/nested/in.stack.golden
  • testdata/src/nolint/in.go
  • testdata/src/nolint/in.lean.golden
  • testdata/src/nolint/in.stack.golden
  • testdata/src/shadowed/in.go
  • testdata/src/shadowed/in.lean.golden
  • testdata/src/shadowed/in.stack.golden
  • testdata/src/stdmix/in.go
  • testdata/src/stdmix/in.lean.golden
  • testdata/src/stdmix/in.stack.golden
  • testdata/src/withmessage/in.go
  • testdata/src/withmessage/in.lean.golden
  • testdata/src/withmessage/in.stack.golden
  • testdata/src/withstack/in.go
  • testdata/src/withstack/in.lean.golden
  • testdata/src/withstack/in.stack.golden
  • testdata/src/wrap/in.go
  • testdata/src/wrap/in.lean.golden
  • testdata/src/wrap/in.stack.golden
  • testdata/src/wrapf/in.go
  • testdata/src/wrapf/in.lean.golden
  • testdata/src/wrapf/in.stack.golden
  • testdata/src/wverb/in.go
  • testdata/src/wverb/in.lean.golden
  • testdata/src/wverb/in.stack.golden
  • testdata/stub/errx/errx.go
  • testdata/stub/errx/go.mod
  • testdata/stub/errx/stacktrace/stacktrace.go
  • testdata/stub/pkgerrors/errors.go
  • testdata/stub/pkgerrors/go.mod

Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/go-lint.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread cmd/errx-migrate/main.go Resolved
Comment thread imports.go Resolved
Comment thread Makefile Resolved
Comment thread stable_test.go Resolved
Comment thread testdata/src/nested/in.lean.golden Resolved
Comment thread testdata/src/withstack/in.lean.golden Resolved
- imports.go: remove an import via its owning declaration rather than the
  first import block, so a github.com/pkg/errors import that lives in a
  second import decl is removed correctly instead of deleting the wrong
  one. Add a multiimport regression fixture (two import decls).
- main.go: handle the os.Stdout write error in default (stdout) mode.
- main.go, golden_test.go, stable_test.go: drop //nolint:gosec directives.
  They are unused under the pinned golangci-lint v2.10.1 (its gosec has no
  G703 rule), which nolintlint reports as a build failure; a newer local
  gosec was masking it.
The lint job now pins golangci-lint v2.12.2 (was v2.10.1). Its newer
gosec bundles the G703 path-traversal-via-taint rule, which fires on file
paths taken from the type checker's own file set and from t.TempDir() in
tests. Those paths are trusted, so G703 is excluded in .golangci.yml
(every other gosec rule stays enabled; the exclude is a no-op on gosec
versions that predate the rule). This keeps `make lint` green on both the
pinned toolchain and newer local installs, without per-line suppressions.
- Pin every GitHub Action to a commit SHA (with a version comment) across
  ci.yml, go-lint.yml, and release.yml.
- Add persist-credentials: false to all checkout steps.
- Add explicit least-privilege permissions (contents: read) to each job.
- Split release.yml into separate snapshot (PR; read-only, caching
  disabled) and release (tag; write) jobs, so the PR path cannot publish
  or share caches across the trust boundary.
- Makefile: set an explicit .DEFAULT_GOAL := help.

Validated with actionlint.
@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@denisvmedia
denisvmedia merged commit 348f1e6 into master May 30, 2026
8 checks passed
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.

2 participants