Skip to content

[BUG] [DOCS] haproxyconn Module : typeError: a bytes-like object is required, not 'str' #57522

Closed as not planned

Description

@Nerigal

Setup
haproxyctl-0.3.1 from pip3 install haproxyctl

Salt Version:
           Salt: 3000.3
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
         Jinja2: 2.11.1
        libgit2: Not Installed
       M2Crypto: 0.35.2
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.6.8 (default, Apr  2 2020, 13:34:55)
   python-gnupg: Not Installed
         PyYAML: 3.13
          PyZMQ: 15.3.0
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.1.4
 
System Versions:
           dist: centos 7.8.2003 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-1127.8.2.el7.x86_64
         system: Linux
        version: CentOS Linux 7.8.2003 Core

Steps to Reproduce the behavior

salt-call --local haproxy.show_backends -l debug

[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[WARNING ] The 'environment' minion config option has been renamed to 'saltenv'. Using dev as the 'saltenv' config value.
[DEBUG   ] Configuration file path: /etc/salt/minion
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG   ] Grains refresh requested. Refreshing grains.
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Loading static grains from /etc/salt/grains
[DEBUG   ] LazyLoaded zfs.is_supported
[DEBUG   ] Determining pillar cache
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] pillarenv 'dev' not found in the configured pillar environments (base)
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded haproxy.show_backends
[DEBUG   ] LazyLoaded direct_call.execute

Passed invalid arguments: a bytes-like object is required, not 'str'.

Usage:

    Show HaProxy Backends

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.show_backends
    
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/cli/caller.py", line 218, in call
    ret['return'] = self.minion.executors[fname](self.opts, data, func, args, kwargs)
  File "/usr/lib/python3.6/site-packages/salt/executors/direct_call.py", line 12, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/modules/haproxyconn.py", line 373, in show_backends
    return ha_conn.sendCmd(ha_cmd)
  File "/usr/local/lib/python3.6/site-packages/haproxy/conn.py", line 33, in sendCmd
    self.sock.send(cmd.getCmd())
TypeError: a bytes-like object is required, not 'str'

Activity

  1. added
    bug
    on Jun 2, 2020
  2. changed the title [-]haproxyconn Module : typeError: a bytes-like object is required, not 'str'[/-] [+][BUG] haproxyconn Module : typeError: a bytes-like object is required, not 'str'[/+] on Jun 3, 2020
  3. dmurphy18 commented on Jun 3, 2020

    @dmurphy18
    Contributor

    @Nerigal The last commit on the haproxyctl was 'Latest commit 8a10db7 on Aug 24, 2015'
    Are you sure that this module is compatible with Python 3.6 which you are using on Redhat 7, since this appears to be a bytes vs str usage issue, typically not an issue in Py 2.7 but not in Python 3.

    Noting that support for Python 3 was released in May 2015, but still quite some time ago, Py 3.4 and Py 3.5 where active then, but Py 3.4 is EOL'd

    Noting that the error is occurring in haproxy code

  4. added
    needs-more-info
    on Jun 3, 2020
  5. added this to the Blocked milestone on Jun 3, 2020
  6. Nerigal commented on Jun 3, 2020

    @Nerigal
    Author

    it is the version installed from pip3 install haproxyctl at least from CentOS 7
    haproxyctl-0.3.1

    and yes i figured that the version on the repo work fine but the pip version is still broken with the encoding of cmd.getCmd()

  7. Nerigal commented on Jun 3, 2020

    @Nerigal
    Author

    Also, i say here because i dont know where but in the official documentation
    there is no mention on what are and how to install the requirements to make salt.modules.haproxyconn work properly

    https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.haproxyconn.html#module-salt.modules.haproxyconn

  8. dmurphy18 commented on Jun 4, 2020

    @dmurphy18
    Contributor

    @Nerigal You state it is pip3 installed, then it is not from CentOS 7 haproxyctl-0.3.1 since it will have been installed from PyPI, and you then state that the pip version is broken.

    SaltStack is not in control of haproxyctl especially the version installed from PyPi. You can log the error with upstream for haproxyctl.

    As for haproxyctl-0.3.1, I fail to find that package on either Centos 7 or Redhat / Fedora sites when searching for it, http://rpms.remirepo.net/rpmphp/zoom.php?rpm=haproxy and http://rpms.remirepo.net/rpmphp/zoom.php?rpm=haproxyctl

    Lastly SaltStack only packages a limit amount of modules when creating a package for a platform, additionally functionality can be pip installed from PyPi. This is done in interest to reduce the size of packages delivered to users with the packages containing the functionality that most users typically use.

  9. Nerigal commented on Jun 4, 2020

    @Nerigal
    Author

    @Nerigal You state it is pip3 installed, then it is not from CentOS 7 haproxyctl-0.3.1 since it will have been installed from PyPI, and you then state that the pip version is broken.

    @dmurphy18 i think you don't get my point here, Yes it is installed by pip 3 and i say at least on CentOS 7 because i have not validated if pip3 would use a different repos / version of the package for example on Ubuntu or else

    so i cannot relate if the same behavior will occur from a pip3 installation under a Debian or such

    As for haproxyctl-0.3.1, I fail to find that package on either Centos 7 or Redhat / Fedora sites when searching for it, http://rpms.remirepo.net/rpmphp/zoom.php?rpm=haproxy and http://rpms.remirepo.net/rpmphp/zoom.php?rpm=haproxyctl

    No its not a RPM packaged
    like i said, haproxyctl-0.3.1 is installed that way pip3 install haproxyctl

    Lastly SaltStack only packages a limit amount of modules when creating a package for a platform, additionally functionality can be pip installed from PyPi. This is done in interest to reduce the size of packages delivered to users with the packages containing the functionality that most users typically use.

    That's fine, as long as the requirements are correctly documented to make the module word properly

  10. self-assigned this
    on Jun 4, 2020
  11. dmurphy18 commented on Jun 4, 2020

    @dmurphy18
    Contributor

    I expect Ubuntu 20.04 version is more up to date and functions correctly with Python 3 since they are shipping https://packages.ubuntu.com/focal/haproxyctl v1.4.3-1 (Debian versioning)

    it’s not spelled out that you have to install it yourself, but on the top of any module documentation that has 3rd party deps it says something to that effect.

  12. added
    doc-correction
    and removed
    bug
    needs-more-info
    on Jun 4, 2020
  13. 15 remaining items

  14. dmurphy18 commented on Sep 23, 2022

    @dmurphy18
    Contributor

    This might be a good candidate for salt extensions

  15. dwoz commented on Oct 15, 2026

    @dwoz
    Contributor

    Thanks for the original report. This issue has been open for more than three years without recent activity and carries a severity label below severity-high. As part of a backlog cleanup, we're closing older low- and medium-severity issues so triage can focus on reports against currently supported releases.

    Closing isn't a judgement that the problem wasn't real — only that the codebase has moved through several releases since this was filed, and much of the surrounding code has changed.

    If you — or anyone else — can still reproduce this on the 3008.x LTS release, please leave a comment with a reproduction and a maintainer will reopen. The original reporter can also reopen directly.

  16. dwoz commented on Oct 17, 2026

    @dwoz
    Contributor

    Reopening — there is an open PR tracking a fix for this: #69554.

  17. reopened this on Oct 17, 2026
  18. dwoz commented on Oct 24, 2026

    @dwoz
    Contributor

    Closing as part of a backlog cleanup — this bug was reported against a version that is no longer supported (pre-3005). The underlying code has moved through several major releases since, and in many cases been rewritten or extracted into a saltext extension.

    If you can still reproduce this on 3006.x LTS or 3008.x LTS, please comment with:

    • A fresh reproduction
    • The output of salt --versions-report

    and a maintainer will reopen. The original reporter can also reopen directly.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdependencydoc-correctiondocumentationpython3severity-lowtime-estimate-single-day

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions