Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw a meanful exception error instead of NPE when no plurals are set #3620

Closed
lordofthejars opened this issue Nov 26, 2021 · 1 comment · Fixed by #3624
Closed

Throw a meanful exception error instead of NPE when no plurals are set #3620

lordofthejars opened this issue Nov 26, 2021 · 1 comment · Fixed by #3624
Assignees
Milestone

Comments

@lordofthejars
Copy link
Contributor

Is your enhancement related to a problem? Please describe

When you create manually a ResourceDefinitionContext and you don't set the plurals field a NPE exception is thrown when you get it using the Kubernetes client

final ResourceDefinitionContext resourceDefinitionContext = new ResourceDefinitionContext.Builder()
            .withGroup("networking.istio.io")
            .withVersion("v1alpha3")
            .withKind("VirtualService")
            .build();

        System.out.println("Namespace: " + namespace);

        final GenericKubernetesResource virtualResource = kubernetesClient.genericKubernetesResources(resourceDefinitionContext).inNamespace(namespace).withName(virtualServiceName).get();

Caused by: java.lang.NullPointerException
	at java.base/java.net.URI$Parser.parse(URI.java:3129)
	at java.base/java.net.URI.<init>(URI.java:623)
	at io.fabric8.kubernetes.client.utils.URLUtils.join(URLUtils.java:50)
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.getNamespacedUrl(OperationSupport.java:164)
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.getNamespacedUrl(OperationSupport.java:169)
	at io.fabric8.kubernetes.client.dsl.base.BaseOperation.getCompleteResourceUrl(BaseOperation.java:818)
	at io.fabric8.kubernetes.client.dsl.base.BaseOperation.getMandatory(BaseOperation.java:188)
	at io.fabric8.kubernetes.client.dsl.base.BaseOperation.get(BaseOperation.java:156)
	at io.fabric8.kubernetes.client.dsl.base.BaseOperation.get(BaseOperation.java:89)

Describe the solution you'd like

Inform why it is failing.

Describe alternatives you've considered

No response

Additional context

No response

@shawkins
Copy link
Contributor

Let's make sure that kind is required, then default to default to pluralizing the kind if plural is not specified.

shawkins added a commit to shawkins/kubernetes-client that referenced this issue Nov 29, 2021
@shawkins shawkins self-assigned this Nov 29, 2021
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Nov 29, 2021
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Nov 29, 2021
@manusa manusa added this to the 5.11.0 milestone Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants