Skip to content

🐛 pkg/envtest: validate config when handling CRDs#3512

Open
orangecms wants to merge 1 commit intokubernetes-sigs:mainfrom
platform-system-interface:envtest-crd-check-config
Open

🐛 pkg/envtest: validate config when handling CRDs#3512
orangecms wants to merge 1 commit intokubernetes-sigs:mainfrom
platform-system-interface:envtest-crd-check-config

Conversation

@orangecms
Copy link
Copy Markdown

@orangecms orangecms commented May 3, 2026

The error message is adapted from pkg/client.
Otherwise, if nil is passed, it crashes with a longer stack trace.

See https://mastodon.social/@CyReVolt/116507340236420167

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @orangecms!

It looks like this is your first PR to kubernetes-sigs/controller-runtime 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/controller-runtime has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: orangecms
Once this PR has been reviewed and has the lgtm label, please assign joelanford for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested review from inteon and vincepri May 3, 2026 07:36
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 3, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @orangecms. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 3, 2026
@orangecms orangecms force-pushed the envtest-crd-check-config branch 2 times, most recently from cb6494a to a8d8086 Compare May 3, 2026 07:43
The error message is adapted from pkg/client.
Otherwise, if nil is passed, it crashes with a longer stack trace.

Signed-off-by: Daniel Maslowski <info@orangecms.org>
@orangecms orangecms force-pushed the envtest-crd-check-config branch from a8d8086 to c2f605f Compare May 3, 2026 07:44
@orangecms orangecms changed the title 🐛 pkg/envtest: validate config 🐛 pkg/envtest: validate config when handling CRDs May 3, 2026
Comment thread pkg/envtest/crd.go

// InstallCRDs installs a collection of CRDs into a cluster by reading the crd yaml files from a directory.
func InstallCRDs(config *rest.Config, options CRDInstallOptions) ([]*apiextensionsv1.CustomResourceDefinition, error) {
if config == nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hi @orangecms, thanks for trying to help out but I am not in favor of merging this. Assuming that nil is a valid value for pointer arguments to a function or method when the arg is not explicitly documented as such is generally wrong and a programming mistake. Panicing is how the function signals this so the author can correct that mistake.

If you look at the go stdlib, you will find that nilchecking parameters is not commonly done.

/hold

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi, can you help me understand?

pkg/client does have that check, so it would be inconsistent to sometimes have the check, sometimes not.

Wouldn't the error returned be what allows for graceful handling and obtaining an understanding of the error? What would otherwise be the reason to have nil checks, such as in pkg/client?

Copy link
Copy Markdown
Member

@alvaroaleman alvaroaleman May 5, 2026

Choose a reason for hiding this comment

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

Yep, seems to be an oversight, the rest of the codebase doesn't have such checks and we don't plan on changing that.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants