Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

rabbitmq_user throws "ValueError: need more than 1 value to unpack" in some cases #1278

Closed
dwcramer opened this issue Nov 24, 2015 · 12 comments

Comments

@dwcramer
Copy link

I've been getting intermittent failures of rabbitmq_user so I added a print statement around line 137 to see what's going on:

    def get(self):
        users = self._exec(['list_users'], True)

        for user_tag in users:

            print "==================="
            print user_tag
            print "==================="

            user, tags = user_tag.split('\t')

That indeed shows me what's happening (see longer listing at bottom). Note the second item in the list is:

===================
Last login: Mon Nov 23 22:30:00 EST 2015 on ???
===================

It appears that the list_users command is getting some extra stuff back from the shell in the form of the "Last login" message. I'm not sure what the most correct fix is for this. I'll hack something in a local copy of rabbitmq_user.py for now and leave the correct fix for someone else.

TASK: [ssilab.rabbitmq | Add administrators] **********************************
failed: [127.0.0.1] => (item=admin) => {"failed": true, "item": "admin", "parsed": false}
BECOME-SUCCESS-rreeqhoomprvtnmnvudttadepypjvdcd
===================
guest   [administrator]
===================
===================
Last login: Mon Nov 23 22:30:00 EST 2015 on ???
===================
Traceback (most recent call last):
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1448335803.77-119755739299357/rabbitmq_user", line 1857, in <module>
    main()
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1448335803.77-119755739299357/rabbitmq_user", line 230, in main
    if rabbitmq_user.get():
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1448335803.77-119755739299357/rabbitmq_user", line 144, in get
    user, tags = user_tag.split('\t')
ValueError: need more than 1 value to unpack
OpenSSH_6.9p1, LibreSSL 2.1.7
debug1: Reading configuration data /Users/davcrame/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: /etc/ssh/ssh_config line 102: Applying options for *
debug1: auto-mux: Trying existing master
debug1: mux_client_request_session: master session id: 2
Shared connection to 127.0.0.1 closed.
@dwcramer
Copy link
Author

FWIW, wrapping it in a try/except seems to work:

    def get(self):
        users = self._exec(['list_users'], True)

        for user_tag in users:

            try:
                user, tags = user_tag.split('\t')

                if user == self.username:
                    for c in ['[',']',' ']:
                        tags = tags.replace(c, '')

                    if tags != '':
                        self._tags = tags.split(',')
                    else:
                        self._tags = list()

                    self._permissions = self._get_permissions()
                    return True

            except ValueError:
                pass

        return False

@robynbergeron
Copy link
Contributor

[module: messaging/rabbitmq_user.py]

@robynbergeron
Copy link
Contributor

@dwcramer Thanks for submitting this bug report.

@chrishoffman -- thanks in advance for taking a look at this bug report and for your ongoing work in maintaining this module.

@brimcfadden
Copy link

I'm seeing a very similar issue in rabbitmq_vhost.py. Here's the traceback:

Traceback (most recent call last):
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1456160487.69-212194742603415/rabbitmq_vhost", line 2081, in <module>
    main()
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1456160487.69-212194742603415/rabbitmq_vhost", line 132, in main
    if rabbitmq_vhost.get():
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1456160487.69-212194742603415/rabbitmq_vhost", line 83, in get
    name, tracing = vhost.split('\t')
ValueError: need more than 1 value to unpack

A warning message string is appearing where a tab-separated vhost + tracing string is expected (line 82 in the most recent commit):

WARNING: ignoring /etc/rabbitmq/rabbitmq.conf -- location has moved to /etc/rabbitmq/rabbitmq-env.conf

Now, I have fixed my issue acutely by heeding the warning and moving my config file to the new location. This causes the unexpected warning message to not appear. However, the tendency of messages to appear in the output being consumed by these modules indicates that they need to be smarter about reading it.

Like @dwcramer, I had to modify the module to figure out what was going on, because the original traceback didn't include the value being split. I haven't dug deep enough to even know what is generating that output (I'm guessing rabbitmqctl), but possible output should be investigated, and each possibility should be handled appropriately.

@ansibot
Copy link

ansibot commented Sep 13, 2016

@chrishoffman, ping. This issue is still waiting on your response.
click here for bot help

@wkeeling
Copy link
Contributor

wkeeling commented Sep 19, 2016

This issue is likely fixed by ae7f7c2c

That commit introduces a check for valid list_users output before attempting to do any parsing. Although not 100% bulletproof, it should resolve both of the issues above.

@ansibot
Copy link

ansibot commented Oct 6, 2016

@chrishoffman, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Oct 22, 2016

@chrishoffman, ping. This issue is still waiting on your response.
click here for bot help

1 similar comment
@ansibot
Copy link

ansibot commented Nov 6, 2016

@chrishoffman, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Nov 22, 2016

@chrishoffman, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Dec 7, 2016

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

@ansibot
Copy link

ansibot commented Sep 10, 2017

This issue was migrated to ansible/ansible#29242

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants