argoproj / argoproj/argo-workflows
Argo Java Client error when using workflowServiceGetWorkflow request
- Dominant language
- Go
- Stars
- 17k
- Forks
- 3.7k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 138
Description
### Pre-requisites
- [X] I have double-checked my configuration
- [X] I can confirm the issues exists when I tested with `:latest`
- [ ] I'd like to contribute the fix myself (see [contributing guide](https://github.com/argoproj/argo-workflows/blob/master/docs/CONTRIBUTING.md))
### What happened/what you expected to happen?
## The Problem
I am trying to use the Java SDK for Argo Workflows to create and watch workflows for completion. I am able to successfully create the workflows through the Java client without issue. **The workflows also complete their execution successfully without issue.** In order to determine when a workflow has completed, I have built a polling loop that calls the following every few seconds:
```
argoWorkflowServiceApiClient.workflowServiceGetWorkflow(
workflowNamespace,
workflowName,
null,
"status"
);
```
No matter what configuration I supply to this method I always get the following error: `Expected BEGIN_OBJECT but was STRING at line 1 column 105 path $.status.startedAt` (the full stack trace is below).
I have tried issuing this request directly in my browser like so:
```
https://:80/api/v1/workflows//?fields=status
```
And it successfully returns the correct JSON in the browser. I've tried setting the last two arguments to the `workflowServiceGetWorkflow` method (`getOptionsResourceVersion` and `fields` respectively) to both `null`, both empty Strings, etc. but I've had no luck.
In the browser I can see the JSON returned from this API does in-fact use a String for `startedAt` and not an `Object` like is printed in the error message:
```
{
"status": {
"phase": "Succeeded",
"startedAt": "",
"finishedAt": "",
"progress": "36/36"
}
}
```
## Full Stack Trace
```
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 105 path $.status.startedAt
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226) ~[gson-2.8.9.jar:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) ~[gson-2.8.9.jar:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) ~[gson-2.8.9.jar:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) ~[gson-2.8.9.jar:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) ~[gson-2.8.9.jar:?]
at com.google.gson.Gson.fromJson(Gson.java:963) ~[gson-2.8.9.jar:?]
at com.google.gson.Gson.fromJson(Gson.java:928) ~[gson-2.8.9.jar:?]
at com.google.gson.Gson.fromJson(Gson.java:877) ~[gson-2.8.9.jar:?]
at io.argoproj.workflow.JSON.deserialize(JSON.java:146)
at io.argoproj.workflow.ApiClient.deserialize(ApiClient.java:795)
at io.argoproj.workflow.ApiClient.handleResponse(ApiClient.java:1001)
at io.argoproj.workflow.ApiClient.execute(ApiClient.java:925)
at io.argoproj.workflow.apis.WorkflowServiceApi.workflowServiceGetWorkflowWithHttpInfo(WorkflowServiceApi.java:494)
at io.argoproj.workflow.apis.WorkflowServiceApi.workflowServiceGetWorkflow(WorkflowServiceApi.java:471)
```
### Version
V3.4.7
### Paste a small workflow that reproduces the issue. We must be able to run the workflow; don't enter a workflows that uses private images.
```YAML
I cannot share our workflows as they are proprietary, but this error occurs for any and all workflows we try.
```
### Logs from the workflow controller
```text
This error occurs in the client, the controller logs are normal.
```
### Logs from in your workflow's wait container
```text
The workflow logs are normal and the workflow completes successfully.
```
Contributor guide
Research direction
Start at WorkflowServiceApi.java, especially workflowServiceGetWorkflowWithHttpInfo, and trace response handling through ApiClient.java and JSON.java. Compare the API's status.startedAt string shown in the issue with the Java model used during deserialization. Done means the Java client can retrieve workflow status without the Gson type error; no specific test is named, so inspect existing Java client tests if available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kubernetes
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100