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

CoreV1Api#deleteNamespacedService expect wrong response object type #3972

Open
tipame opened this issue Mar 13, 2025 · 2 comments
Open

CoreV1Api#deleteNamespacedService expect wrong response object type #3972

tipame opened this issue Mar 13, 2025 · 2 comments

Comments

@tipame
Copy link

tipame commented Mar 13, 2025

Describe the bug
APIdeleteNamespacedServiceRequest#execute returns V1Service.
Actually server response with V1Status (in terms of lib api).
So client response handler code fails on parsing Status json to V1Service dto:

java.lang.IllegalArgumentException: The field `details` in the JSON string is not defined in the `V1Service` properties. JSON: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Success","details":{"name":"dummy","kind":"services","uid":"7839a223-28f5-495a-a4af-838ca25a4489"}}
	at io.kubernetes.client.openapi.models.V1Service.validateJsonElement(V1Service.java:262)
	at io.kubernetes.client.openapi.models.V1Service$CustomTypeAdapterFactory$1.read(V1Service.java:307)
	at io.kubernetes.client.openapi.models.V1Service$CustomTypeAdapterFactory$1.read(V1Service.java:297)
	at com.google.gson.TypeAdapter$NullSafeTypeAdapter.read(TypeAdapter.java:314)
	at com.google.gson.Gson.fromJson(Gson.java:1361)
	at com.google.gson.Gson.fromJson(Gson.java:1262)
	at com.google.gson.Gson.fromJson(Gson.java:1171)
	at com.google.gson.Gson.fromJson(Gson.java:1137)
	at io.kubernetes.client.openapi.JSON.deserialize(JSON.java:799)
	at io.kubernetes.client.openapi.ApiClient.deserialize(ApiClient.java:909)
	at io.kubernetes.client.openapi.ApiClient.handleResponse(ApiClient.java:1119)
	at io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:1043)
	at io.kubernetes.client.openapi.apis.CoreV1Api.deleteNamespacedServiceWithHttpInfo(CoreV1Api.java:22126)
	at io.kubernetes.client.openapi.apis.CoreV1Api$APIdeleteNamespacedServiceRequest.execute(CoreV1Api.java:22253)

Client Version
23.0.0 | 22.0.1

Kubernetes Version
v1.21.14

Java Version
Java 17

To Reproduce

CoreV1Api api = new CoreV1Api(apiClient);
api.deleteNamespacedService(name, namespace).execute();

Expected behavior
Expect V1Status as a return type for service delete request.

@brendandburns
Copy link
Contributor

The issue here is that that method returns either V1Status or a V1Namespace depending on whether it is actually deleted quickly or not.

We hacked around this with the old client generator, but I think that in moving to the new generator, the hack/fix to make this work got broken.

We'll need to see if there's a good way to fix this in the new client generator.

@brendandburns
Copy link
Contributor

cc @yue9944882

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

No branches or pull requests

2 participants