Skip to content

Conversation

@atombrella
Copy link
Contributor

What this PR does / why we need it:

Use errors.As instead of type-casting, errors.Is for comparison and use of %w for error formatting in fmt.Errorf. The changes do not fully fix all of errorlint. I don't feel comfortable touching files under v1-3 as this may break compatibility with API users.

I have not successfully been able to change the use of switch with comparison of the error type. There are a few instances of this:

pkg/provenance/sign_test.go:401:9: type switch on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)
	switch err.(type) {
	       ^
pkg/strvals/parser.go:247:4: switch on an error will fail on wrapped errors. Use errors.Is to check for specific errors (errorlint)
			case io.EOF:
			^
pkg/strvals/parser.go:379:3: switch on an error will fail on wrapped errors. Use errors.Is to check for specific errors (errorlint)
		case io.EOF:

Special notes for your reviewer:

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so)
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 20, 2025
@atombrella atombrella changed the title Fix more errorlint warnings. Use errors.As and errors.Is for error handling. Fix more errorlint warnings. Use errors.As and errors.Is for error handling. Dec 20, 2025
Use errors.As instead of type-casting, errors.Is for comparison and
use of %w for error formatting in fmt.Errorf. The changes do not fully
fix all of errorlint. I don't feel comfortable touching files under v1-3
as this may break compatibility with api users.

Signed-off-by: Mads Jensen <atombrella@users.noreply.github.com>
Signed-off-by: Mads Jensen <atombrella@users.noreply.github.com>
@atombrella atombrella force-pushed the feature/errorlint_as_round_2 branch from b16ab16 to 711204d Compare December 20, 2025 11:33
@atombrella atombrella force-pushed the feature/errorlint_as_round_2 branch from 6ec8cd9 to 711204d Compare December 20, 2025 16:16
@atombrella atombrella force-pushed the feature/errorlint_as_round_2 branch from 18e7091 to 6ded2ff Compare December 20, 2025 17:13
Signed-off-by: Mads Jensen <atombrella@users.noreply.github.com>
Signed-off-by: Mads Jensen <atombrella@users.noreply.github.com>
@atombrella atombrella force-pushed the feature/errorlint_as_round_2 branch from 6ded2ff to e597f7f Compare December 20, 2025 17:14
gjenkins8
gjenkins8 previously approved these changes Jan 17, 2026
Copy link
Member

@gjenkins8 gjenkins8 left a comment

Choose a reason for hiding this comment

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

Changes look good. Thanks!

These large refactor PRs, while valid, can be difficult to merge due to coordinating two maintainers before a conflict arises.

Can you please fix the conflicts, and I can re-approve. And hopefully another maintainer before a conflict arises.

@atombrella
Copy link
Contributor Author

atombrella commented Jan 17, 2026

Changes look good. Thanks!

These large refactor PRs, while valid, can be difficult to merge due to coordinating two maintainers before a conflict arises.

Can you please fix the conflicts, and I can re-approve. And hopefully another maintainer before a conflict arises.

@gjenkins8 @TerryHowe Sure. I have fixed the merge-conflicts.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request improves error handling across the Helm codebase by adopting modern Go error handling patterns. It replaces direct error comparisons with errors.Is, type assertions with errors.As, and uses %w instead of %v in fmt.Errorf to properly wrap errors.

Changes:

  • Replaced direct error comparisons (err == specificError) with errors.Is(err, specificError) for better wrapped error support
  • Replaced type assertions (err.(*Type)) with errors.As(err, &variable) for safer type checking
  • Changed error formatting from %v to %w in fmt.Errorf calls to preserve error chains
  • Grouped related constants in engine.go for better code organization

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/strvals/parser.go Updated io.EOF comparisons to use errors.Is
pkg/strvals/literal_parser.go Updated io.EOF comparisons to use errors.Is (contains critical bugs)
pkg/storage/driver/sql_test.go Changed ErrReleaseNotFound comparison to errors.Is
pkg/storage/driver/sql.go Updated error wrapping to use %w format
pkg/storage/driver/secrets_test.go Changed ErrReleaseNotFound comparisons to errors.Is
pkg/storage/driver/cfgmaps_test.go Changed ErrReleaseNotFound comparisons to errors.Is
pkg/registry/transport.go Updated io.EOF comparison to use errors.Is
pkg/kube/wait.go Replaced StatusError type assertion with errors.As
pkg/kube/client.go Updated error comparisons and type assertions to use errors.Is and errors.As
pkg/engine/engine.go Grouped constants and updated error wrapping to use %w
pkg/downloader/manager.go Updated error wrapping to use %w format
pkg/downloader/chart_downloader_test.go Changed ErrNoOwnerRepo comparison to errors.Is
pkg/downloader/chart_downloader.go Changed ErrNoOwnerRepo comparison to errors.Is
pkg/cmd/upgrade.go Changed ErrReleaseNotFound comparison to errors.Is
pkg/cmd/template.go Updated error wrapping to use %w format
pkg/cmd/search_repo.go Updated error wrapping to use %w format
pkg/cmd/search_hub.go Updated error wrapping to use %w format
pkg/cmd/rollback.go Updated error wrapping to use %w format
pkg/cmd/load_plugins.go Replaced InvokeExecError type assertion with errors.As
pkg/cmd/lint.go Updated error wrapping to use %w format
pkg/cmd/dependency_build.go Replaced ErrRepoNotFound type assertion with errors.As
pkg/chart/loader/archive/archive.go Updated io.EOF comparison and error wrapping
pkg/action/validate.go Updated error wrapping to use %w format
pkg/action/upgrade.go Updated error wrapping to use %w format
pkg/action/package_test.go Changed error comparison to errors.Is
pkg/action/install.go Updated error wrapping to use %w format
internal/sympath/walk.go Changed filepath.SkipDir comparisons to errors.Is
internal/plugin/runtime_subprocess_test.go Replaced InvokeExecError type assertion with errors.As
internal/plugin/runtime_subprocess.go Replaced exec.ExitError type assertions with errors.As
internal/plugin/installer/local_installer_test.go Changed ErrPluginNotADirectory comparison to errors.Is

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

atombrella and others added 2 commits January 18, 2026 15:15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Mads Jensen <mje@inducks.org>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Mads Jensen <mje@inducks.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants