fix(quality): test panic, PR-time CI, lint cleanup - #146
Merged
Conversation
The helmRelease fixture was missing the Info field, causing prepareOutput to panic on release.Info.LastDeployed.Time. Production callers always receive a non-nil Info from helm; the fixture should reflect that.
The repo only had image-build workflows gated to push events on main/test/prod. PRs (including dependabot updates) had no automated gate, so dep bumps had to be validated by hand. Adds a CI workflow that runs on pull_request and pushes to main.
Clears all 24 lint warnings flagged on main. Semantics-preserving:
errcheck (15) - wrap discarded defer Close/Remove and discarded
fmt.Fprintln / w.Flush / w.WriteAll returns with explicit '_ ='
instead of adding real error handling.
staticcheck (5):
- S1001 in pkg/helm/artifacthub.go: replace copy loop with copy()
- QF1001 in cmd/root.go: De Morgan's law on format check
- ST1005 (x2) in pkg/output/output.go: lowercase error strings
ineffassign (2) in cmd/root.go: discard first err with '_' (NOTE:
the original NewArtifactHubCachedPackageClient and ahClient.List
errors were already silently dropped before this commit; this
preserves that behavior but does not fix it).
unused (3):
- pkg/containers/images_test.go: remove dead setupKubeObjects /
teardownKubeObjects helpers and the now-unused context import.
- pkg/helm/helm_repo_exporter.go: remove dead helmRepocacheFile.
There was a problem hiding this comment.
Code Review
This pull request focuses on code cleanup and improving error handling consistency. Key changes include removing unused variables and functions, replacing manual loops with the "copy" function, and explicitly ignoring errors in deferred calls and output formatting. Review feedback identifies critical issues where "defer" is called before error checks, potentially causing nil pointer panics, and highlights the risks of ignoring errors during client initialization and data listing in the helm handling logic.
4 tasks
pkg/output/output.go: move 'defer file.Close()' below the os.Create error check so a failed Create can't trigger a nil-receiver panic on the deferred Close. cmd/root.go: replace the '_ =' suppressions of NewArtifactHubCachedPackageClient and ahClient.List with proper error checks. Also fix the misleading error message that attributed the helm-repo-hub client error to the artifact hub client.
golangci-lint v2.x requires golangci-lint-action v7; v6 errors with 'golangci-lint v2 is not supported by golangci-lint-action v6'.
RamanKharchee
approved these changes
May 12, 2026
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.
This PR fixes #
Checklist
Description
What's the goal of this PR?
Address three pre-existing quality gaps surfaced while validating the recent dependabot dependency bumps:
pkg/helm.Test_prepareOutputwas panicking on everygo testrun onmain.golangci-lintwarnings onmain.What changes did you make?
Structured as three independent, bisectable commits:
1.
test(helm): fix Test_prepareOutput nil-pointer panicThe
helmReleasetest fixture inpkg/helm/findscore_test.gowas missing theInfofield.prepareOutputaccessesrelease.Info.LastDeployed.Time, panicking on nilInfo. Production callers always receive a non-nilInfofrom helm. One-line fix to the fixture.2.
ci: add PR validation workflow (build, lint, test)New
.github/workflows/ci.yamlrunsgo build,golangci-lint, andgo test -raceon every PR tomainand every push tomain. Existing image-build workflows (only on push) are untouched.3.
chore: clear golangci-lint warningsClears all 24 lint issues. Semantics-preserving — every change either silences a discarded return with
_/_ =, deletes provably dead code, or applies a trivial rewrite (copy()over a copy loop, De Morgan's law, lowercased error strings).Review Notes → Risks & Counterarguments
cmd/root.go: at lines 385–391 the original code doesahClient, err := NewArtifactHubCachedPackageClient(...)followed byhelmClient, err := NewHelmRepoHubCachedPackageClient(...)then checkserr. Theerrfrom the first call is silently overwritten. The error message at the check site ("error setting up artifact hub client") suggests the original intent was to check the first call. Same pattern withahClient.List()andhelmClient.ListRepo()below. I converted these to explicit_discards to silenceineffassignwithout changing runtime behavior. These remain real bugs — a follow-up should add proper error handling for both calls.defer file.Close()ordering bug also preserved:pkg/output/output.go:146defersfile.Close()before checking theos.Createerror, so a nilfilewould panic on the deferred call. Lint just flags the unchecked Close; the ordering is a separate bug not in scope here.errcheckvia_ =rather than handling: I deliberately silenced discarded returns fromfmt.Fprintln,w.Flush,w.WriteAll,os.Remove,resp.Body.Close. Proper handling (log on failure, surface stream errors, etc.) is a separate decision that shouldn't be bundled with mechanical cleanup. The pre-existing code clearly intended to ignore these; this PR just makes that intent explicit.How Has This Been Tested?
go build ./...— cleangolangci-lint run ./...— 0 issues (from 24 onmain)go test ./...— all packages pass (was failing onpkg/helm.Test_prepareOutputonmain)Validated locally on
golangci-lint v2.11.3and Go 1.26.1, on top of currentmain(HEADf85179b).