zowe / zowe-client-python-sdk

Eclipse Public License 2.0
39 stars 25 forks source link

list_dsn_members function causes most following functions to fail #299

Closed john-craig closed 2 months ago

john-craig commented 3 months ago

Describe the bug

list_dsn_members function leaves X-IBM-Attributes key set as member in request arguments, borking most following requests.

Expected and actual results

Details about the behavior:

  1. Expected behavior: Other zos_files functions function normally after call of list_dsn_members
  2. Actual behavior: Requests after using the list_dsn_members function using the same zos_files object fail with, {"category":1,"rc":4,"reason":12,"message":"X-IBM-Attributes","details":["member"]}
  3. Applicable log files:
Traceback (most recent call last):
  File "/home/ibmuser/.local/bin/gamacles", line 8, in <module>
    sys.exit(gamacles_cli())
             ^^^^^^^^^^^^^^
  File "/home/ibmuser/.local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ibmuser/.local/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/ibmuser/.local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ibmuser/.local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ibmuser/.local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ibmuser/.local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ibmuser/.local/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ibmuser/.local/lib/python3.11/site-packages/gamacles/main.py", line 150, in linkedit
    dev_linkedit(dry_run, steplib, amblist, ctx.obj['config'])
  File "/home/ibmuser/.local/lib/python3.11/site-packages/gamacles/development/linkedit.py", line 200, in dev_linkedit
    amblist_steplib(username, load_module, steplib_dataset, zos_files, zos_jobs)
  File "/home/ibmuser/.local/lib/python3.11/site-packages/gamacles/development/linkedit.py", line 15, in amblist_steplib
    ensure_dataset(f'{username}.{load_module}.AMBLIST', AMBLIST_DATASET_OPTS, zos_files)
  File "/home/ibmuser/.local/lib/python3.11/site-packages/gamacles/development/common.py", line 95, in ensure_dataset
    res = zos_files.list_dsn(dsname)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ibmuser/.local/lib/python3.11/site-packages/zowe/zos_files_for_zowe_sdk/files.py", line 125, in list_dsn
    response_json = self.request_handler.perform_request("GET", custom_args)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ibmuser/.local/lib/python3.11/site-packages/zowe/core_for_zowe_sdk/request_handler.py", line 71, in perform_request
    self.__validate_response()
  File "/home/ibmuser/.local/lib/python3.11/site-packages/zowe/core_for_zowe_sdk/request_handler.py", line 135, in __validate_response
    raise RequestFailed(self.response.status_code, output_str)
zowe.core_for_zowe_sdk.exceptions.RequestFailed: HTTP Request has failed with status code 500. 

Describe your environment

github-actions[bot] commented 3 months ago

Thank you for creating a bug report. We will investigate the bug and evaluate its impact on the product. If you haven't already, please ensure you have provided steps to reproduce the bug and as much context as possible.

john-craig commented 3 months ago

This is a temporary workaround:

def list_dsn_members_safe(dataset, zos_files):
    res = zos_files.list_dsn_members(dataset)

    if "headers" in zos_files.request_arguments and "X-IBM-Attributes" in zos_files.request_arguments["headers"]:
        zos_files.request_arguments["headers"]["X-IBM-Attributes"] = None

    return res