salt icon indicating copy to clipboard operation
salt copied to clipboard

[BUG] nacl returns bytes instead of string

Open faivirol opened this issue 3 years ago • 1 comments

Description Continuation of #52960 which was closed prematurely.

When directly using a pillar encrypted (and then decrypted) by nacl, it returns bytes instead of a string. In some cases this will get converted to the string b'mystring' instead of mystring. I am using v3005.1.

As a workaround, I have changed my state file to manually decode the bytes before using them (like {{ pillar['mypillar'].decode("utf-8") }}).

If this is intended behavior, please let me know and I will update the documentation.

Steps to Reproduce the behavior I ran into this when attempting to use basic auth in an orchestration, getting the username/password wrapped in b'':

<state id>:
  salt.runner:
    - name: http.query
    - arg:
        - "https://httpbin.org/basic-auth/username/password"
    - kwarg:
        username: "{{ pillar['username'] }}"
        password: "{{ pillar['password'] }}"
        method: GET

This will fail if the username or password pillars are processed by nacl first. With -l debug, the log says 'username': "b'username'", 'password': "b'password'" in the line right before Requesting URL https://httpbin.org/basic-auth/username/password using GET method.

Expected behavior The bytes should be decoded into UTF-8 before being returned.

faivirol avatar Dec 30 '22 16:12 faivirol

Duplicate: #60653

OrangeDog avatar Dec 30 '22 21:12 OrangeDog