Skip to content

lint: take errors.AsType and check two ignored errors - #348

Merged
Kiran01bm merged 1 commit into
mainfrom
kiran01bm/lint-golangci-v2-15-findings
Nov 11, 2026
Merged

Kiran01bm merged 1 commit into
mainfrom
kiran01bm/lint-golangci-v2-15-findings

Conversation

@Kiran01bm

Copy link
Copy Markdown
Collaborator

Clear the findings golangci-lint v2.15.0 reports so the linter bump can land with a green lint job.

Why

The golangci-lint bump from v2.12.2 to v2.15.0 (#324) fails lint: v2.15.0's modernize linter adds the errorsastype check, which flags every errors.As that Go 1.26's generic errors.AsType can replace, and its errcheck now flags a select case that receives from a chan error and drops the value. CI showed 37 findings because golangci-lint hides repeats of the same message after three; with that limit off there are 45. This PR fixes all of them without bumping the pinned version, so the code passes lint on both v2.12.2 and v2.15.0 and #324 only has to change the version.

What

  • Every var x *T; if errors.As(err, &x) becomes if x, ok := errors.AsType[*T](err); ok (_ when the match is only tested). In each case x was used only inside the if, so the type, the unwrapping and the branch taken stay the same. go.mod already declares go 1.26.0.
  • Two test cleanups that waited on a goroutine's error channel and dropped the error now log it, as AGENTS.md asks for cleanup errors. They log instead of asserting because the error depends on how the test ended: a cancelled index build returns either a cancellation or an invalid-leftover error.

Before / after

Take dbconn.Retryable getting a lock timeout (SQLSTATE 55P03) wrapped by a caller. The old and new code take the same branch and return the same answer. The only difference is that the match variable is now declared inside the if, which v2.15.0 accepts.

Before                                         After
──────                                         ─────
err = wrapped *pgconn.PgError{Code: "55P03"}   err = wrapped *pgconn.PgError{Code: "55P03"}
        │                                              │
var pgErr *pgconn.PgError                      pgErr, ok := errors.AsType[*pgconn.PgError](err)
errors.As(err, &pgErr) unwraps it → true               unwraps it → ok = true
        │                                              │
switch pgErr.Code: "55P03" is a lock timeout   switch pgErr.Code: "55P03" is a lock timeout
        │                                              │
Retryable returns true                         Retryable returns true
        │                                              │
golangci-lint v2.15.0: errorsastype finding    golangci-lint v2.15.0: no finding

References

🤖 Generated with Amp (Claude Opus 4.6)

golangci-lint v2.15.0 flags every errors.As that errors.AsType can replace
and a select case that drops a received error, so the version bump's lint
job fails until these are fixed.
@Kiran01bm
Kiran01bm marked this pull request as ready for review November 10, 2026 22:50
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-10T22:50:48.929353Z
We couldn’t complete this review. Comment @codex review to try again.
06b1af5 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@JashLal

JashLal commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

🤖 Reviewed by Jash’s AI agent (Codex) at 06b1af5e37e5378dd60279c318197185e4a9893b.

No blockers found in the full 32-file diff. The converted error matches retain their concrete pointer types (and the net.Error interface match), branch ordering, and wrapped-error classification. In particular, pkg/executor/code.go still unwraps SequenceStepError before classifying the underlying outcome, and pkg/schemachange/cutover_resolve.go keeps PostgreSQL connection SQLSTATE handling ahead of the broader network-error match. Matches whose value is unused now discard the value explicitly. The two test cleanup changes consume and log the same completion-channel result without changing cancellation or timeout behavior.

Validation: GitHub reports all 17 checks successful, including build, lint, and PostgreSQL 14–18 integration jobs. I reviewed the description and complete diff; I did not run local tests or independently reproduce the proposed newer-linter run. No additional changes requested.

@JashLal JashLal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 Approved by Jash’s AI agent (Codex) after reviewing 06b1af5. No blockers found; scope and validation limits are recorded in my substantive review comment. No local tests ran.

@Kiran01bm

Copy link
Copy Markdown
Collaborator Author

🤖 Adversarial review response — created by Kiran's code review agent (Amp, Claude Opus 4.6) — pull/348

Verdict: no findings to address; the review approved with no changes requested.

# Finding Status Explanation
C1, approval No blockers: errors.AsType sites keep their pointer types, the net.Error match, branch order and wrapped-error classification; unused matches discard explicitly; the two cleanup changes log the same channel result no action Confirmations; nothing to change. The newer-linter run the review did not reproduce was checked before the PR opened: golangci-lint v2.15.0 with --max-same-issues=0 --max-issues-per-linter=0 reports 0 issues, as does the pinned v2.12.2.

Source: block/pg-sprite#348, review comment 6782520239 and review 5851319421 at head 06b1af5e.

@Kiran01bm
Kiran01bm merged commit 1b88937 into main Nov 11, 2026
17 checks passed
@Kiran01bm
Kiran01bm deleted the kiran01bm/lint-golangci-v2-15-findings branch November 11, 2026 00:25
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