Repository navigation
🌱 Use errors.AsType instead of errors.As - #3222
Merged
openshift-merge-bot[bot] merged 1 commit intoDec 3, 2026
Merged
Conversation
Go 1.26 added the generic errors.AsType, which returns the matched error and a bool. Using it removes the pre-declared target variables, scopes the matched error to the if statement, and checks the target type at compile time instead of at run time. This is a mechanical change with no behavior change. It covers every errors.As call site in the repository. Signed-off-by: Per G. da Silva <pegoncal@redhat.com>
👷 Deploy request for olmv1 pending review.Visit the deploys page to approve it
|
This was referenced Dec 2, 2026
Member
|
/lgtm |
rashmigottipati
approved these changes
Dec 2, 2026
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: rashmigottipati The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
openshift-merge-bot
Bot
merged commit Dec 3, 2026
65ff5e0
into
operator-framework:main
33 checks passed
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Go 1.26 added the generic
errors.AsType, which returns the matched error and a bool:This removes the target variables declared before each check, scopes the matched error to its
ifstatement, and checks the target type at compile time instead of at run time (errors.Aspanics on an invalid target).The change is mechanical and doesn't change behavior. It covers all 11
errors.Ascall sites in the repo:internal/object-controller/controllers/clusterobjectset_controller.go(3)internal/operator-controller/config/config.go(2)internal/shared/util/http/certlog.go(1)internal/shared/util/error/terminal.go(1)test/internal/e2e/steps/steps.go(2),hooks.go(1),platform/steps/demo_steps.go(1)Where the matched error isn't used, the code is
_, ok := .... Otherwise the value is bound and scoped to itsifstatement.I left some redundant code alone to keep this mechanical. In
certlog.go, the outererrors.Unwraploop does nothing extra, becauseerrors.AsTypealready searches the whole error chain. TheexitErr != nilcheck inhooks.gois also redundant. Either can be cleaned up in a follow-up.Verified with
make lint(0 issues) andmake test-unit(pass).Reviewer Checklist
Summary by CodeRabbit