Skip to content

fix: add ModulePath() to TestDeps for Go 1.26 compatibility#2646

Merged
shubham-cmyk merged 9 commits into
kyverno:mainfrom
henrysachs:fix/go-1.26-testdeps-module-path
Mar 11, 2026
Merged

fix: add ModulePath() to TestDeps for Go 1.26 compatibility#2646
shubham-cmyk merged 9 commits into
kyverno:mainfrom
henrysachs:fix/go-1.26-testdeps-module-path

Conversation

@henrysachs

@henrysachs henrysachs commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Description

chainsaw fails to compile with Go 1.26 because testing.testDeps gained a new required method ModulePath() string in Go 1.26.

Error

github.com/kyverno/chainsaw/pkg/runner/internal.TestDeps does not implement
testing.testDeps (missing method ModulePath)

Root cause

pkg/runner/internal/test_deps.go implements the testing.testDeps interface but is missing ModulePath() string added in Go 1.26.

Fix

  1. Added the missing method to `TestDeps`:
func (*TestDeps) ModulePath() string {
    return ""
}
  1. Bumped go.mod to go 1.26.0.

Fixes #2645

@henrysachs henrysachs requested a review from a team as a code owner February 27, 2026 12:18
PodLogs in Finally/Catch invokes kubectl as subprocess; without a real
cluster it exits non-zero, causing fail() to be called. expectedFail was
incorrectly set to false (zero value). Corrected to true to match actual
semantics.

Signed-off-by: Henry Sachs <[email protected]>
@henrysachs

henrysachs commented Feb 27, 2026

Copy link
Copy Markdown
Contributor Author

Question for reviewers regarding the test fix:

The pre-existing test TestStepProcessor_Run/try,_catch_and_finally_operation_with_apply_handler was already failing on main (confirmed with Go 1.25 — the test fails, the compile error just masked it). But maybe my local setup ist just wrong so help is appreciated!

Happy to adjust the fix based on your guidance.

@henrysachs

Copy link
Copy Markdown
Contributor Author

@eddycharly if you would be able to take a look that would be highly appreciated

@henrysachs

Copy link
Copy Markdown
Contributor Author

sorry for pinging but @shubham-cmyk maybe you can help me get this through?

Avoid the gosec temp file path warning, update Trivy to a working action release, and keep the runner unit test independent from kubectl side effects.

Signed-off-by: Henry Sachs <[email protected]>
Keep the original catch and finally pod log coverage in place even though the unit test still fails locally without the previous expectation change.

Signed-off-by: Henry Sachs <[email protected]>
@henrysachs

Copy link
Copy Markdown
Contributor Author

Local repro is green now: kind-backed make tests and golangci-lint both pass on the branch. The only remaining blocker should be the missing milestone on the PR. Could you @eddycharly or @shubham-cmyk please approve the workflows and set a milestone to have the CI turn green? :)

@shubham-cmyk shubham-cmyk added this to the v0.2.15 milestone Mar 11, 2026
@shubham-cmyk

Copy link
Copy Markdown
Member

@henrysachs the code QL is failing please check

Move CodeQL scanning to trivy-action v0.35.0 so the workflow uses the newer Trivy release instead of the broken v0.69.1 default.

Signed-off-by: Henry Sachs <[email protected]>
@henrysachs

Copy link
Copy Markdown
Contributor Author

@shubham-cmyk i hope that a action bump fixes it. I think this is related to the trivy issues: https://github.com/aquasecurity/trivy/discussions/10265

@codecov

codecov Bot commented Mar 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 67.00%. Comparing base (f2bc418) to head (3c16078).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/loaders/resource/load.go 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2646      +/-   ##
==========================================
+ Coverage   66.95%   67.00%   +0.05%     
==========================================
  Files         149      149              
  Lines        5698     5707       +9     
==========================================
+ Hits         3815     3824       +9     
  Misses       1623     1623              
  Partials      260      260              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Cover the new ModulePath shim and exercise LoadFromURI through a local HTTP server so patch coverage reflects the CI fix paths.

Signed-off-by: Henry Sachs <[email protected]>
@henrysachs

Copy link
Copy Markdown
Contributor Author

@shubham-cmyk i made fixes for codecov. Atleast i hope to fix the coverage 😅

Extract the downloaded file read path behind a tiny read-seeker helper so seek and read errors can be covered without weakening the gosec-safe handle-based flow.

Signed-off-by: Henry Sachs <[email protected]>
@henrysachs

henrysachs commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

@shubham-cmyk i had to do this via the interface to adress the gosec finding and make it testable for codecov, so could you approve again?

@shubham-cmyk

Copy link
Copy Markdown
Member

@shubham-cmyk i had to do this via the interface to adress the gosec finding and make it testable for codecov, so could you approve again?

Done

@henrysachs

Copy link
Copy Markdown
Contributor Author

@shubham-cmyk so all checks passed, did you have some time to have a look on the changes?

Comment thread pkg/loaders/resource/load.go Outdated
Comment thread pkg/loaders/resource/load.go Outdated
@shubham-cmyk

Copy link
Copy Markdown
Member

@henrysachs just update this we are ready to go

Co-authored-by: Shubham Gupta <[email protected]>
Signed-off-by: Henry Sachs <[email protected]>
@henrysachs

Copy link
Copy Markdown
Contributor Author

@shubham-cmyk there you go, thanks for the review!

@henrysachs henrysachs requested a review from shubham-cmyk March 11, 2026 20:06
@shubham-cmyk shubham-cmyk merged commit 5f2001f into kyverno:main Mar 11, 2026
15 checks passed
@henrysachs

Copy link
Copy Markdown
Contributor Author

@shubham-cmyk I know I'm really a bit pushy here, but could you also please publish a release from this?

@henrysachs henrysachs deleted the fix/go-1.26-testdeps-module-path branch March 13, 2026 10:32
@shubham-cmyk

Copy link
Copy Markdown
Member

@henrysachs i have pinged @eddycharly for the release

@henrysachs

Copy link
Copy Markdown
Contributor Author

@eddycharly could you please have a look into this?

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.

[Bug] chainsaw v0.2.14 fails to compile with Go 1.26 (missing ModulePath() on TestDeps)

3 participants