zowe / api-layer

The API Mediation Layer provides a single point of access for mainframe service REST APIs.
Eclipse Public License 2.0
56 stars 63 forks source link

Special characters in DSN names not supported #2728

Closed wolfgang0101 closed 1 year ago

wolfgang0101 commented 1 year ago

Background of the question We are trying to get a PDS member that has a special character in the DSN name through the ZOWE Explorer in VS Code. In our case the '#' (hash tag character). The connection is made through the APIML using the authentication service. But we are getting the following error: Retrieving response from zowe.List Error: z/OSMF REST API Error: Rest API failure with HTTP(S) status 400 <!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1></body></html>

From our point of view the APIML tries to make the request through z/OSMF without escaping the special character. But we are not sure if we put all parameter together correctly.

Could some indicate us if there are some particular parameters to set to support the special characters?

We executed the test case also without the APIML performing simply the request through the z/OSMF. It worked without problems. We executed the test case also with the ZOWE CLI command for PDS datasets (connected through APIML). Same problem.

Steps to Reproduce

Include relevant data Snippet of the profile definition: [...] "profiles": { "mfApiml": { "type": "zosmf", "properties": { "basePath": "ibmzosmf/api/v1", "encoding": "IBM-1141" }, "secure": [] }, [...] "base": { "type": "base", "properties": { "host": "gateway-zowe.mydomain", "rejectUnauthorized": true, "tokenType": "apimlAuthenticationToken" }, "secure": [ "tokenValue" ] } }, [...]

Expected behavior The PDS name should appear in the section 'Data set' of Zowe Explorer. It should be openable in the same way as other datasets without special character.

Environment Windows: Windows 10 (10.0.19044) VSCode Verison: 1.72.0 Zowe Explorer: 2.5.0 APIML: 2.4 z/Os: 2.4

pablocarle commented 1 year ago

Hi @wolfgang0101 I did a test with Zowe Explorer, and even without API ML configured as the authentication service I'm getting errors handling datasets with special characters on them, for example, I managed to allocate a sequential dataset with such characters as APIMLPC.TEST.#123 and I can open it, but when trying to save it I get this error:

image

Strangely this does not happen with a PDS, no matter if the special character is in the dataset name or member.

I will also try it out with the API ML as the authentication service and record the difference.

wolfgang0101 commented 1 year ago

Hi @pablocarle we didn't try it with a file creation. The only thing we can contribute is that if we go through the Api ML, we have this problem of the hash tag character. If we connect (the Zowe Explorer) directly to the z/OSMF and execute there the commands we get the correct answer.

If we can assist you in tracing down the problem, please let us know.

pablocarle commented 1 year ago

Hi @wolfgang0101, I'm getting the same error as you reported:

z/OSMF REST API Error: Rest API failure with HTTP(S) status 400 <!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1></body></html>

z/OSMF REST API Error: Rest API failure with HTTP(S) status 400 <!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1></body></html> Error: z/OSMF REST API Error: Rest API failure with HTTP(S) status 400 <!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1></body></html>

Both when trying to open a sequential dataset or a PDS member containing a # character.

However, I don't see the vscode request going through the API ML, I need somehow to confirm what exactly they are calling. For example, I assumed they are calling the z/OSMF API through the gateway, like /ibmzosmf/api/v1/zosmf/restfiles/ds/APIMLPC.TEST.#123

I tried with the character raw and encoded. I can confirm that these go indeed through the gateway. With the encoded character it works as expected and with the raw character:

< HTTP/1.1 500 
< Vary: Origin
< Vary: Access-Control-Request-Method
< Vary: Access-Control-Request-Headers
< Pragma: no-cache
< X-IBM-Txid: tx000000000001911E
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< X-Powered-By: Servlet/3.1
< Cache-Control: no-store
< Content-Language: en-US
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Mon, 06 Feb 2023 15:08:20 GMT
< Connection: close
< 
* Closing connection 0
{"category":1,"rc":4,"reason":3,"message":"Data set name is not valid","details":["IKJ56231I UTILITY DATA SET NOT ALLOCATED, SYSTEM OR INSTALLATION ERROR+    ","IKJ56231I TEXT UNIT X'0002' CONTAINS INVALID PARAMETER    "]}%                                                  

This error is different from the one we get in vscode. We can fix this by making sure the request path is properly encoded when routing the call. But for the original report, we need to involve the vscode zowe explorer extension team, as I don't see the request originating from the extension going through the gateway.

wolfgang0101 commented 1 year ago

Thanks @pablocarle for the confirmation. Do I have now to change the type of this request from 'question' into something else?

For us it is only important that the issue will be fixed. Preferably directyl in the Api ML because we want to use it also for other types of requests. But as You already stated, we don't know if it is the same error since the Explorer is showing us another one...

pablocarle commented 1 year ago

@wolfgang0101 I believe this needs to be opened as an issue in the zowe explorer vs code extension repository as well, to analyse if the request is created in a different way when api ml is involved. The request that results in HTTP 400 gets rejected before reaching the application code. For other sources of requests, encoding the characters in a URL will work with the API ML.

pablocarle commented 1 year ago

Closing because it's already being worked on in @zowe/vscode-extension-for-zowe#2133