Skip to content

fix: cannot access local variable 'identifier' where it is not associ… #10030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iphoneintosh
Copy link

SUMMARY

If community.general.proxmox is called on an existing lxc container with state=present and force: true then we take a code path in which a debugging message is printed but the identifier was no defined beforehand, leading to the error "An error occurred: cannot access local variable 'identifier' where it is not associated with a value".

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

proxmox

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type) small_patch Hopefully easy to review labels Apr 20, 2025
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-9 Automatically create a backport for the stable-9 branch backport-10 Automatically create a backport for the stable-10 branch labels Apr 20, 2025
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! Can you please add a changelog fragment? Thanks!

@@ -890,6 +890,7 @@ def lxc_present(self, vmid, hostname, node, update, force):
self.module.exit_json(
changed=False, vmid=vmid, msg="VM %s already exists." % identifier
)
identifier = self.format_vm_identifier(vmid, lxc["name"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

The only path where it isn't defined is in else of the above ifs:

Suggested change
identifier = self.format_vm_identifier(vmid, lxc["name"])
else:
identifier = self.format_vm_identifier(vmid, lxc["name"])

@felixfontein
Copy link
Collaborator

FYI, the proxmox content from this repository is currently being moved to https://github.com/ansible-collections/community.proxmox. Once that repo is ready, you'll have to create a new PR there, as from that point this repo is only accepting bugfixes that have already been merged into the other repo. For now you can use this PR in this repo to continue working on the PR. (The other repo has no CI yet, for example.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-9 Automatically create a backport for the stable-9 branch backport-10 Automatically create a backport for the stable-10 branch bug This issue/PR relates to a bug check-before-release PR will be looked at again shortly before release and merged if possible. module module new_contributor Help guide this first time contributor plugins plugin (any type) small_patch Hopefully easy to review stale_ci CI is older than 7 days, rerun before merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants