Skip to content

Conversation

@mayankmani-sde
Copy link
Collaborator

SUMMARY

Rationale
The issue was caused by the variable is_member being referenced inside the error-handling block before it was initialized. When a missing source triggered the failure path, is_member had not yet been defined, resulting in an unhandled UnboundLocalError.
Design Decision
To ensure consistent variable initialization and error handling, is_member is now explicitly initialized to False before the try block.
This guarantees that even if an exception is raised before its assignment, the variable remains accessible during failure conditions.

#2357

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

zos_fetch

ADDITIONAL INFORMATION
- name: Fetch file
      zos_fetch:
        src: /tmp/out.txt.nope
        dest: /tmp/fetched
      register: result

    - name: Print result.
      ansible.builtin.debug:
        msg: "{{ result }}"
fatal: [zvm]: FAILED! => {
    "binary": false,
    "changed": false,
    "checksum": null,
    "data_set_type": null,
    "dest": null,
    "encoding": null,
    "msg": "The source '/tmp/out.txt.nope' does not exist or is uncataloged.",
    "rc": 0,
    "src": null,
    "stderr": null,
    "stderr_lines": null,
    "stdout": null,
    "stdout_lines": null
}

@mayankmani-sde mayankmani-sde added the Bug Something isn't working as designed. label Oct 24, 2025
@mayankmani-sde mayankmani-sde marked this pull request as ready for review October 24, 2025 08:40
Copy link
Collaborator

@fernandofloresg fernandofloresg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me will approve once the SPS pipeline is shared

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working as designed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] zos_fetch when source does not exist, is_member where it is not associated with a value appears in output

2 participants