Retrieving multiple z/OS system variables by name returns the expected data list. However, passing a single variable name in the input list results in an empty list within the VariableGetResponse object. This occurs because the underlying JSON response structure changes from a JSON array to a single JSON object, which the SDK fails to parse.
Steps to Reproduce
Case 1: Requesting Multiple Variables (Successful)
VariableGet variableGet = new VariableGet(connection);
VariableGetInputData getInputData = VariableGetInputFactory.createZosVariable(sysplexName, systemName, List.of("var1", "var2"));
response = variableGet.get(getInputData);// Result: Response correctly contains a list of both variables and their values.
Case 2: Requesting a Single Variable (Fails to Populate)
VariableGet variableGet = new VariableGet(connection);
VariableGetInputData getInputData = VariableGetInputFactory.createZosVariable(sysplexName, systemName, List.of("var1"));
response = variableGet.get(getInputData);// Result: response.getSystemVariableList() returns an empty list [].
Root Cause Analysis
The issue stems from how the SDK deserializes the incoming JSON payload. The z/OSMF REST API alters its JSON root schema based on whether one or multiple variables are requested:
- Multiple Variables Structure: z/OSMF returns a root JSON object wrapping a JSON array. The SDK is designed to parse this format correctly.
{"system-variable-list":[{"name":"var1","value":"value1","description":"first variable description"},{"name":"var2","value":"value2","description":null}]}
- Single Variable Structure: z/OSMF returns a single JSON object directly at the root, completely omitting the system-variable-list array container.
{"name":"var1","value":"value1","description":"first variable description"}
Retrieving multiple z/OS system variables by name returns the expected data list. However, passing a single variable name in the input list results in an empty list within the VariableGetResponse object. This occurs because the underlying JSON response structure changes from a JSON array to a single JSON object, which the SDK fails to parse.
Steps to Reproduce
Case 1: Requesting Multiple Variables (Successful)
VariableGet variableGet = new VariableGet(connection);
VariableGetInputData getInputData = VariableGetInputFactory.createZosVariable(sysplexName, systemName, List.of("var1", "var2"));
response = variableGet.get(getInputData);// Result: Response correctly contains a list of both variables and their values.
Case 2: Requesting a Single Variable (Fails to Populate)
VariableGet variableGet = new VariableGet(connection);
VariableGetInputData getInputData = VariableGetInputFactory.createZosVariable(sysplexName, systemName, List.of("var1"));
response = variableGet.get(getInputData);// Result: response.getSystemVariableList() returns an empty list [].
Root Cause Analysis
The issue stems from how the SDK deserializes the incoming JSON payload. The z/OSMF REST API alters its JSON root schema based on whether one or multiple variables are requested:
{"system-variable-list":[{"name":"var1","value":"value1","description":"first variable description"},{"name":"var2","value":"value2","description":null}]}
{"name":"var1","value":"value1","description":"first variable description"}