Skip to content

fix(action): crd resources can be empty#31578

Merged
joejulian merged 10 commits into
helm:mainfrom
manute:main
Feb 11, 2026
Merged

fix(action): crd resources can be empty#31578
joejulian merged 10 commits into
helm:mainfrom
manute:main

Conversation

@manute

@manute manute commented Nov 26, 2025

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

It checks if the resources are empty to see if this issue #31552 is fixed
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/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 26, 2025
@benoittgt

Copy link
Copy Markdown
Contributor

Hello @manute

Thanks for the patch. Could you add a test that reproduces the issue in #31552 to validate the fix and prevent future regressions?

@pull-request-size pull-request-size Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 26, 2025
@manute

manute commented Nov 26, 2025

Copy link
Copy Markdown
Contributor Author

Done @benoittgt , thanks!

banjoh
banjoh previously approved these changes Nov 26, 2025

@banjoh banjoh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes look OK

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since you added the error check, can you add a test for nil File?

@manute

manute commented Nov 26, 2025

Copy link
Copy Markdown
Contributor Author

@TerryHowe

Copy link
Copy Markdown
Contributor

TerryHowe
TerryHowe previously approved these changes Nov 27, 2025

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

@TerryHowe TerryHowe added the Has One Approval This PR has one approval. It still needs a second approval to be merged. label Dec 13, 2025
@robertsirc

Copy link
Copy Markdown
Member

Hi @manute first thank you for the PR. I pulled it down built it and ran the test and I got the following:

=== RUN TestInstall/install_chart_with_only_crds helpers_test.go:63: running cmd (attempt 1): install crd-test testdata/testcharts/chart-with-only-crds --namespace default helpers_test.go:69: expected no error, got: 'INSTALLATION FAILED: failed to install CRD crds/test-crd.yaml: resources are empty' --- FAIL: TestInstall/install_chart_with_only_crds (0.00s)

@manute

manute commented Dec 22, 2025

Copy link
Copy Markdown
Contributor Author

@robertsirc fixed! thanks

TerryHowe
TerryHowe previously approved these changes Jan 3, 2026

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

@banjoh

banjoh commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

@manute do you mind resolving the current conflicts?

Signed-off-by: Manuel Alonso <[email protected]>
@pull-request-size pull-request-size Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 9, 2026
banjoh
banjoh previously approved these changes Jan 11, 2026
@TerryHowe

Copy link
Copy Markdown
Contributor

Broken tests.

--- FAIL: TestInstalLCRDs (0.00s)
    install_test.go:1100: 
        	Error Trace:	/home/runner/work/helm/helm/pkg/action/install_test.go:1100
        	Error:      	Received unexpected error:
        	            	failed to install CRD crds/foo.yaml: resources are empty
        	Test:       	TestInstalLCRDs
--- FAIL: TestInstalLCRDs_AlreadyExist (0.00s)
    install_test.go:1155: 
        	Error Trace:	/home/runner/work/helm/helm/pkg/action/install_test.go:1155
        	Error:      	Expected nil, but got: &errors.errorString{s:"failed to install CRD crds/foo.yaml: resources are empty"}
        	Test:       	TestInstalLCRDs_AlreadyExist
FAIL

@manute
manute dismissed stale reviews from banjoh and TerryHowe via 0f949a9 January 11, 2026 20:09
@pull-request-size pull-request-size Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 11, 2026
Manuel Alonso and others added 2 commits January 13, 2026 19:21
@manute

manute commented Jan 23, 2026

Copy link
Copy Markdown
Contributor Author

@TerryHowe fixed, thanks

Comment thread pkg/action/install_test.go Outdated
Comment thread pkg/action/install_test.go Outdated

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

@joejulian joejulian added this to the 4.1.2 milestone Feb 11, 2026
@joejulian
joejulian merged commit 70899a6 into helm:main Feb 11, 2026
5 checks passed
@scottrigby scottrigby added bug Categorizes issue or PR as related to a bug. needs-pick Indicates that a PR needs to be cherry-picked into the next release candidate. picked Indicates that a PR has been cherry-picked into the next release candidate. and removed Has One Approval This PR has one approval. It still needs a second approval to be merged. needs-pick Indicates that a PR needs to be cherry-picked into the next release candidate. labels Mar 10, 2026
@scottrigby scottrigby modified the milestones: 4.1.2, 4.1.3 Mar 11, 2026
superShen0916 pushed a commit to superShen0916/helm that referenced this pull request May 9, 2026
Signed-off-by: superShen0916 <[email protected]>

Backport the fix from helm#31578 to dev-v3 branch.

The installCRDs function previously could panic in several scenarios:
- When a CRD object has a nil File field (accessing obj.File.Data)
- When a CRD object has nil File.Data (passing nil to KubeClient.Build)
- When KubeClient.Build returns an empty resource list (accessing res[0])
- When RESTClientGetter is nil (calling ToDiscoveryClient/ToRESTMapper)

Added nil and empty checks to return descriptive errors instead of
panicking in all these cases.

Closes helm#31552

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: superShen0916 <[email protected]>
superShen0916 pushed a commit to superShen0916/helm that referenced this pull request May 9, 2026
Signed-off-by: shenpeng.sp0916 <[email protected]>

Backport the fix from helm#31578 to dev-v3 branch.

The installCRDs function previously could panic in several scenarios:
- When a CRD object has a nil File field (accessing obj.File.Data)
- When a CRD object has nil File.Data (passing nil to KubeClient.Build)
- When KubeClient.Build returns an empty resource list (accessing res[0])
- When RESTClientGetter is nil (calling ToDiscoveryClient/ToRESTMapper)

Added nil and empty checks to return descriptive errors instead of
panicking in all these cases.

Closes helm#31552

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: shenpeng.sp0916 <[email protected]>
superShen0916 pushed a commit to superShen0916/helm that referenced this pull request May 10, 2026
Signed-off-by: shenpeng.sp0916 <[email protected]>

Backport the fix from helm#31578 to dev-v3 branch.

The installCRDs function previously could panic in several scenarios:
- When a CRD object has a nil File field (accessing obj.File.Data)
- When a CRD object has nil File.Data (passing nil to KubeClient.Build)
- When KubeClient.Build returns an empty resource list (accessing res[0])
- When RESTClientGetter is nil (calling ToDiscoveryClient/ToRESTMapper)

Added nil and empty checks to return descriptive errors instead of
panicking in all these cases.

Closes helm#31552

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: shenpeng.sp0916 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Categorizes issue or PR as related to a bug. picked Indicates that a PR has been cherry-picked into the next release candidate. 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.

7 participants