salt logging with plain str (ascii) with unicode chars causes UnicodeDecodeError PY2

Created on 12 Jul 2017  ·  35Comments  ·  Source: saltstack/salt

Description of Issue/Question

I'm building SLS Packages to deploy to windows-minions, and i noticed if i have files with an undersorce in its name that i want to copy to the minion, with cache_dir: TRUE, then the pkg.refresh_db fails.

Setup

this ist the init.sls i'm using:

{% set LOG_PATH = salt['grains.get']('SALT_TMP_LOG') %} 

WinArborDemo:
  '12.00.11':
    full_name: 'WinArborDemo'
    installer: salt://win/repo-ng/WinArborDemo/WinArbor.msi
    install_flags: '/l* "{{ LOG_PATH }}WinArborDemo_inst.log"  /quiet /norestart'
    uninstaller: salt://win/repo-ng/WinArborDemo/WinArbor.msi
    uninstall_flags: '/l* "{{ LOG_PATH }}WinArborDemo_uninst.log"  /quiet /norestart'
    msiexec: TRUE
    locale: de_DE
    reboot: FALSE
    cache_dir: TRUE

and beside this init.sls there is the setup.exe and a source dir, wich contains stuff needed on windows, this is where the undersorces disrupt.

this is the output of the pkg.refresh_db:

win7-pc01:
    ----------
    failed:
        0
    success:
        0
    total:
        0
win10-pc01:
    ----------
    failed:
        0
    success:
        0
    total:
        0

if i move the WinArborDemo directory out of my repo-ng it all works, just fine and i get the correct amount of packages.

This is what the master logs:

2017-07-12 18:17:10,944 [salt.loaded.int.fileserver.roots][TRACE   ][27908] roots: /srv/salt/win/repo-ng/WinArborDemo/source/Info-Center/Ratgeber/Daten/Werbung/Bosse/Werbung-Bosse.jpg relative path is win/repo-ng/WinArborDemo/source/Info-Center/Ratgeber/Daten/Werbung/Bosse/Werbung-Bosse.jpg
2017-07-12 18:17:10,944 [salt.master      ][ERROR   ][27908] Error in function _file_list:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/master.py", line 1629, in run_func
    ret = getattr(self, func)(load)
  File "/usr/lib/python2.7/site-packages/salt/fileserver/__init__.py", line 756, in file_list
    ret.update(self.servers[fstr](load))
  File "/usr/lib/python2.7/site-packages/salt/fileserver/roots.py", line 421, in file_list
    return _file_lists(load, 'files')
  File "/usr/lib/python2.7/site-packages/salt/fileserver/roots.py", line 397, in _file_lists
    _add_to(ret['files'], path, root, files)
  File "/usr/lib/python2.7/site-packages/salt/fileserver/roots.py", line 343, in _add_to
    log.trace('roots: Processing %s', abs_path)
  File "/usr/lib/python2.7/site-packages/salt/log/mixins.py", line 35, in trace
    self.log(getattr(logging, 'TRACE', 5), msg, *args, **kwargs)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1231, in log
    self._log(level, msg, args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/log/setup.py", line 327, in _log
    self, level, msg, args, exc_info=exc_info, extra=extra
  File "/usr/lib64/python2.7/logging/__init__.py", line 1285, in _log
    record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
  File "/usr/lib/python2.7/site-packages/salt/log/setup.py", line 361, in makeRecord
    exc_info, func)
  File "/usr/lib/python2.7/site-packages/salt/log/setup.py", line 208, in __init__
    self.colormsg = '%s%s%s' % (cmsg, self.getMessage(), reset)
  File "/usr/lib64/python2.7/logging/__init__.py", line 329, in getMessage
    msg = msg % self.args
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 99: ordinal not in range(128)

And i'm sure that it's because of the quotes because, i changed the filenames of the file that was the last logged (i made a "-" for every "_") and the error jumped to the next file with "_" in it.

Versions Report

I also tried it with Master and Minions on 2016.4.11, so they were all on the same version
but i had exactly the same error there, that's why i upgraded.

Master:

Salt Version:
           Salt: 2017.7.0

Dependency Versions:
           cffi: 1.5.2
       cherrypy: 3.6.0
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: 0.24.0
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: 2.10
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.24.0
         Python: 2.7.12 (default, Jun 28 2016, 06:57:42) [GCC]
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.2.2

System Versions:
           dist: SuSE 4.0 x86_64
         locale: UTF-8
        machine: x86_64
        release: 4.4.27-2-default
         system: Linux
        version: OSS  4.0 x86_64

Minions:

win7-pc01:
    Salt Version:
               Salt: 2016.11.6

    Dependency Versions:
               cffi: 1.10.0
           cherrypy: unknown
           dateutil: 2.5.3
          docker-py: Not Installed
              gitdb: 0.6.4
          gitpython: 2.0.8
              ioflo: 1.5.5
             Jinja2: 2.9.4
            libgit2: Not Installed
            libnacl: 1.4.5
           M2Crypto: Not Installed
               Mako: 1.0.4
       msgpack-pure: Not Installed
     msgpack-python: 0.4.8
       mysql-python: Not Installed
          pycparser: 2.17
           pycrypto: 2.6.1
       pycryptodome: Not Installed
             pygit2: Not Installed
             Python: 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)]
       python-gnupg: 0.3.8
             PyYAML: 3.11
              PyZMQ: 16.0.1
               RAET: Not Installed
              smmap: 0.9.0
            timelib: 0.2.4
            Tornado: 4.4.1
                ZMQ: 4.1.6

    System Versions:
               dist:   
            machine: x86
            release: 7
             system: Windows
            version: 7 6.1.7601 SP1 Multiprocessor Free
win10-pc01:
    Salt Version:
               Salt: 2016.11.6

    Dependency Versions:
               cffi: 1.10.0
           cherrypy: unknown
           dateutil: 2.5.3
          docker-py: Not Installed
              gitdb: 0.6.4
          gitpython: 2.0.8
              ioflo: 1.5.5
             Jinja2: 2.9.4
            libgit2: Not Installed
            libnacl: 1.4.5
           M2Crypto: Not Installed
               Mako: 1.0.4
       msgpack-pure: Not Installed
     msgpack-python: 0.4.8
       mysql-python: Not Installed
          pycparser: 2.17
           pycrypto: 2.6.1
       pycryptodome: Not Installed
             pygit2: Not Installed
             Python: 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)]
       python-gnupg: 0.3.8
             PyYAML: 3.11
              PyZMQ: 16.0.1
               RAET: Not Installed
              smmap: 0.9.0
            timelib: 0.2.4
            Tornado: 4.4.1
                ZMQ: 4.1.6

    System Versions:
               dist:   
            machine: AMD64
            release: 10
             system: Windows
            version: 10 10.0.14393  Multiprocessor Free
Bug P3 severity-medium stale

Most helpful comment

Here is my fix
/usr/lib/python2.7/site-packages/salt/log/mixins.py

# This is function has been updated in a newer comment below
import salt.ext.six as six
import copy

def _text_to_unicode(obj):
    '''
    Converts plain strings to Unicode recusively, so all items
    are Unicode utf-8 which is ascii compatible,
    :param obj:
        Any object type, its recusively investigated for strings to convert
    :rtype: unicode
    :codeauthor: Damon Atkins <https://github.com/damon-atkins>
    '''
    if isinstance(obj, list):
        return [_text_to_unicode(x) for x in obj]
    if isinstance(obj, tuple):
        return tuple(_text_to_unicode(x) for x in obj)
    elif isinstance(obj,six.string_types) and not isinstance(obj,six.text_type):
        return obj.decode('utf-8')
    else:
        return copy.copy(obj)

The following needs to be implemented on every function, not just trace. I can raise a PR for this but I need the salt teams feedback, and which version to apply it too.

class LoggingTraceMixIn(object):
    '''
    Simple mix-in class to add a trace method to python's logging.
    '''


    def trace(self, msg, *args, **kwargs):
        try:
            self.log(getattr(logging, 'TRACE', 5), msg, *args, **kwargs)
        except UnicodeDecodeError:
            self.log(getattr(logging, 'TRACE', 5), msg, *_text_to_unicode(args), **_text_to_unicode(kwargs))
        except:
            raise

All 35 comments

You have not got your files in the correct place on the master. As it's not even pulling down the sls file.
refresh_db total should not be 0.

See https://github.com/saltstack/salt/issues/40397

However I suspect you have Unicode Chars in filenames on the master. i.e. _ is not an ascii _ Check all filenames for Unicode Chars.

Thanks for your answer.
It think the places of the files should be okay, beacause if i move the /srv/salt/win/repo-ng/WinArborDemo directory away from the salt/win/repo-ng, all other packages are synced and pkg.refresh_db looks like this:

win7-pc01:
    ----------
    failed:
        0
    success:
        46
    total:
        46
win10-pc01:
    ----------
    failed:
        0
    success:
        46
    total:
        46

But what can i do with the unicode Characters? I can't just change the filenames, because the programm needs them the way they are.

Can you clarify which file has unicode characters when running the refresh?

I suspect the salt file server can not handle unicode characters.
Try this on the master or minion salt-call cp.list_master

As a work around you can use http:// (web server for exe and files) instead of salt://

The logging in salt can also cause this
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 99: ordinal not in range(128)
When python2 tries to take Unicode and convert it to ascii to join it to another string, because in PY2 strings are not Unicode by default.
e.g. log.trace('roots: Processing %s', abs_path) i.e. 'roots: Processing %s' PY2 string, and I suspect abs_path is Unicode.

Be aware you may have more issue with TRACE or DEBUG.

Also try running the master with export PYTHONIOENCODING=utf8 and salt, salt-call, see if it makes a difference.

@Ch3LL
This is the list of files wich have unicode chars:
it's in /srv/salt/win/repo-ng/WinArborDemo/source

source/Info-Center/Ratgeber/Daten/Werbung/Bosse/Haftungsausschluß.doc
source/Info-Center/Ratgeber/Daten/Monatsbilder/März.jpg
source/Bilder/Sch_00/asterfrikmönch2.jpg
source/Bilder/Sch_00/asterveilchenkönigin.jpg
source/Bilder/Sch_00/asterfrikmönch.jpg
source/Bilder/Sch_00/asterrosaerfüllung.jpg
source/Bilder/bilder63/wüstenr1.jpg
source/Formular/verwaltu/Börsengesuch.lsv
source/Formular/verwaltu/Börsengesuch.lst
source/Formular/verwaltu/EKÜbers1.lst
source/Formular/verwaltu/EKÜbers2.LST
source/Formular/verwaltu/EKÜbers3.lst
source/Formular/verwaltu/EKÜbers3.lsv
source/Formular/verwaltu/EKÜbers2.lsv
source/Formular/verwaltu/Packzetteländerungsprot.LST
source/Formular/verwaltu/Packzetteländerungsprot.lsv
source/Formular/verwaltu/EKÜbers1.lsv
source/Formular/etikett/sat 25x200-abriß.lbl
source/Formular/etikett/Güse_Crosa.lbv
source/Formular/etikett/sat 25x250-abriß.lbv
source/Formular/etikett/citizen17x250abriß.lbv
source/Formular/etikett/Güse_A4.lbl
source/Formular/etikett/sat 25x250-abriß.lbl
source/Formular/etikett/sato2,5x25 mitabriß.lbl
source/Formular/etikett/sat 25x200-abriß.lbp
source/Formular/etikett/citizen17x250abriß.lbp
source/Formular/etikett/sat 25x200-abriß.lbv
source/Formular/etikett/Güse_DinA5.lbv
source/Formular/etikett/Güse_Crosa.lbl
source/Formular/etikett/citizen17x250abriß.lbl
source/Formular/etikett/sat 25x250-abriß.lbp
source/Formular/etikett/Güse_DinA5.lbl
source/Formular/etikett/sato2,5x25 mitabriß.lbv
source/Formular/etikett/sato2,5x25 mitabriß.lbp
source/Formular/etikett/Güse_A4.lbv
source/Formular/projekt/Kürzung_exkl.lsv
source/Formular/projekt/Kürzung_inkl.lst
source/Formular/projekt/Kürzung_inkl.lsp
source/Formular/projekt/Kürzung_inkl.lsv
source/Formular/projekt/Kürzung_exkl.lst
source/Formular/projekt/Kürzung_exkl.lsp
source/Formular/zahlung/RgEinZusfErlösgr.lsv
source/Formular/zahlung/RgEinZusfErlösgr.LST

@damon-atkins
the salt-call gives me this:

admin:/srv/salt/win/repo-ng/WinArborDemo # salt-call cp.list_master
local:

on both master or minion.

The export PYTHONIOENCODING=utf8 didn't help , and i also tried to change the loglevel back to default (was on "garbage" before), but that didn't do the thing either (that was what you suggested, if i understood you correctly?).

Bit more detail, for you to try.

# systemctl stop salt-master  # assuming systemd 
# PYTHONIOENCODING=utf8 salt-master -l quiet
# PYTHONIOENCODING=utf8 salt-call -l info cp.list_master 
local:
    - .git/FETCH_HEAD
    - .git/HEAD
    - .git/ORIG_HEAD
    - .git/config
    - .git/description
etc

Basically if you get no output from cp.list_master then lots of things will not work.

Created this as a test file name and it failed for me with 2016.11.3
0unicode_file_name_üöÜä.txt

After the following quick hack it worked.

diff  /usr/lib/python2.7/site-packages/salt/fileserver/roots.py /usr/lib/python2.7/site-packages/salt/fileserver/roots.py.org
339c339
<                 #log.trace('roots: Processing %s', abs_path)
---
>                 log.trace('roots: Processing %s', abs_path)
341,344c341,344
<                 #log.trace(
<                 #    'roots: %s is %sa link',
<                 #    abs_path, 'not ' if not is_link else ''
<                 #)
---
>                 log.trace(
>                     'roots: %s is %sa link',
>                     abs_path, 'not ' if not is_link else ''
>                 )
348c348
<                 #log.trace('roots: %s relative path is %s', abs_path, rel_path)
---
>                 log.trace('roots: %s relative path is %s', abs_path, rel_path)
362,365c362,365
<                     #log.trace(
<                     #    'roots: %s symlink destination is %s',
<                     #    abs_path, link_dest
<                     #)
---
>                     log.trace(
>                         'roots: %s symlink destination is %s',
>                         abs_path, link_dest
>                     )
376,379c376,379
<                     #log.trace(
<                     #    'roots: %s relative path is %s',
<                     #    abs_path, rel_dest
<                     #)
---
>                     log.trace(
>                         'roots: %s relative path is %s',
>                         abs_path, rel_dest
>                     )

Here is my fix
/usr/lib/python2.7/site-packages/salt/log/mixins.py

# This is function has been updated in a newer comment below
import salt.ext.six as six
import copy

def _text_to_unicode(obj):
    '''
    Converts plain strings to Unicode recusively, so all items
    are Unicode utf-8 which is ascii compatible,
    :param obj:
        Any object type, its recusively investigated for strings to convert
    :rtype: unicode
    :codeauthor: Damon Atkins <https://github.com/damon-atkins>
    '''
    if isinstance(obj, list):
        return [_text_to_unicode(x) for x in obj]
    if isinstance(obj, tuple):
        return tuple(_text_to_unicode(x) for x in obj)
    elif isinstance(obj,six.string_types) and not isinstance(obj,six.text_type):
        return obj.decode('utf-8')
    else:
        return copy.copy(obj)

The following needs to be implemented on every function, not just trace. I can raise a PR for this but I need the salt teams feedback, and which version to apply it too.

class LoggingTraceMixIn(object):
    '''
    Simple mix-in class to add a trace method to python's logging.
    '''


    def trace(self, msg, *args, **kwargs):
        try:
            self.log(getattr(logging, 'TRACE', 5), msg, *args, **kwargs)
        except UnicodeDecodeError:
            self.log(getattr(logging, 'TRACE', 5), msg, *_text_to_unicode(args), **_text_to_unicode(kwargs))
        except:
            raise

@damon-atkins

THANK YOU!

Sry i'm a bit late, was working the whole day, but your fix made my whole day. It works like charm!!!
I added the function you wrote, and completed the logging functions with the exception handling. And now my pkg.refresh_db locks like this:

win7-pc01:
    ----------
    failed:
        0
    success:
        49
    total:
        49
win10-pc01:
    ----------
    failed:
        0
    success:
        49
    total:
        49 

The WinArborDemo package is alright and i had another package (ClassPadManager), where i noticed the same behaviour, but even that package works now :-)

@Helmi-helmutson can you change the title of the issue. To
salt logging with plain str (ascii) with unicode chars causes UnicodeDecodeError PY2
Thanks

I was having this problem with win_pkg when I added unicode support to it some time ago, I had to be very careful about what I logged.

Hi @Ch3LL,
Info Need tag is no longer required. It's with Salt Team to decide on the fix direction.
Cheers

ping @Ch3LL

Hi @terminalmage Can you have a look at this one. And decide to add this or wait for everything to be prefixed with u' or something else.

This will be fixed in the Oxygen release.

When I finish my current task, I will look at ways of fixing this specific error in a bugfix release ahead of Oxygen.

@damon-atkins 's solution fixed it also for me.

New version of the code, added support for dicts (and OrderedDict which will not be needed here)

Here is my newer fix
/usr/lib/python2.7/site-packages/salt/log/mixins.py

import salt.ext.six as six
from salt.utils.odict import OrderedDict

def _text_to_unicode(obj):
    '''
    Converts plain PY2 strings to Unicode recursively, so all items
    are Unicode from utf-8 source which is ascii compatible.
    :param obj:
        Any object type, its recursively investigated for strings to convert
    :rtype: obj
    :codeauthor: Damon Atkins <https://github.com/damon-atkins>
    '''

    # This code is only for PY2
    if not six.PY2:
        return obj
    # Deal this common iterms first float,int,unicode
    if isinstance(obj, (float, int, six.text_type)):
        return obj
    if isinstance(obj,six.string_types) and not isinstance(obj,six.text_type):
        return obj.decode('utf-8')
    # Deal with complex objects
    if isinstance(obj, list):
        return [_text_to_unicode(x) for x in obj]
    if isinstance(obj, tuple):
        return tuple(_text_to_unicode(x) for x in obj)
    if isinstance(obj, OrderedDict):
        # create a new dict to force the key to be unicode
        new=OrderedDict()
        for key, data in six.iteritems(obj):
            new[_text_to_unicode(key)]=_text_to_unicode(data)
        return new
    if isinstance(obj, dict):
        # create a new dict to force the key to be unicode
        new={}
        for key, data in six.iteritems(obj):
            new[_text_to_unicode(key)]=_text_to_unicode(data)
        return new
    # Reach here if object type is not processed.
    return obj

The following needs to be implemented on every function, not just trace. I can raise a PR for this but I need the salt teams feedback, and which version to apply it too. See https://github.com/saltstack/salt/issues/42278#issuecomment-315374098 for the old version.

class LoggingTraceMixIn(object):
    '''
    Simple mix-in class to add a trace method to python's logging.
    '''


    def trace(self, msg, *args, **kwargs):
        try:
            self.log(getattr(logging, 'TRACE', 5), msg, *args, **kwargs)
        except UnicodeDecodeError:
            self.log(getattr(logging, 'TRACE', 5), msg, *_text_to_unicode(args), **_text_to_unicode(kwargs))
        except Exception:
            raise

edit changed except to except Exception

FYI One person resolved their issue, when they notice a cut and past issue. e.g. how word changes a - to a longer dash. Look for unexpected characters.
Is your edit replacing characters with fancy versions of the same character.
Examples:
" or ' http://www.iclarified.com/38772/how-to-disable-curly-quotes-in-mac-os-x-mavericks
-

Why did you comment out the OrderedDict part? Also, bare exceptions are bad, you should use except Exception instead. Finally, we should not assume utf-8 as the encoding. Use __salt_system_encoding__ instead, as this will detect the system encoding and allow non-utf8 unicode encodings to work.

utf-8 is the format of the python code files # -*- coding: utf-8 -*- i.e. log.debug('utf-8 string here'). Hence __salt_system_encoding__ was not chosen. I believe the sls files assume utf-8. as well.

On error, the code assumes mix of ASCII & utf-8 in PY2 strings is the cause of the issue and turns everything into PY2 Unicode using decode(). The Unicode is accept by log.* having chars>126

My assumption was OrderedDict is not relevant to logs. Could be wrong? If a OrderDict can turn up it should be included, it was comment out because I was unsure.

utf8 mention in input from salt/renderers/yaml.py

                    data = _yaml_result_unicode_to_utf8(data)
            elif __opts__.get('yaml_utf8'):
....
def _yaml_result_unicode_to_utf8(data):
.....
        data = data.encode('utf-8') 
# I suspect the above should be decode. In PY3 'data.encode()' would return type byte.   
....

Therefore utf-8 was most likely going to be the input.

OrderedDicts can be passed as logging arguments (really just about _anything_ can be), so they could be present in the args tuple.

Anyone reading this thread _yaml_result_unicode_to_utf8(data) has been removed from salt/renderers/yaml.py in development.

FYI https://github.com/saltstack/salt/issues/42278#issuecomment-318913952 this issue still exists in 2017.7.2 if you upgrade you need to re-apply the patch/fix

This currently still exists in 2017.7.3 =/
Ugh.

Please label this to be fixed in 2017.7.3

@Ch3LL Please remove the Info Needed Label

@terminalmage you stated "When I finish my current task, I will look at ways of fixing this specific error in a bugfix release ahead of Oxygen." I know we are still working towards oxygen, but i'll go ahead and assign this to you to look at aftwerwards.

This currently still exists in 2018.3 =/
Ugh.

Also the fix from @damon-atkins doesn't work for me on 2018.3 (had to revert to 2017.7.4 to make the fix above working again):

[ERROR   ] An un-handled exception was caught by salt's global exception handler:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 70: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/local/bin/salt-ssh", line 10, in <module>
    salt_ssh()
  File "/usr/local/lib/python2.7/site-packages/salt/scripts.py", line 420, in salt_ssh
    client.run()
  File "/usr/local/lib/python2.7/site-packages/salt/cli/ssh.py", line 24, in run
    ssh = salt.client.ssh.SSH(self.config)
  File "/usr/local/lib/python2.7/site-packages/salt/client/ssh/__init__.py", line 326, in __init__
    self.fsclient = salt.fileclient.FSClient(self.opts)
  File "/usr/local/lib/python2.7/site-packages/salt/fileclient.py", line 1401, in __init__
    self.channel = salt.fileserver.FSChan(opts)
  File "/usr/local/lib/python2.7/site-packages/salt/fileserver/__init__.py", line 836, in __init__
    self.fs.update()
  File "/usr/local/lib/python2.7/site-packages/salt/fileserver/__init__.py", line 471, in update
    self.servers[fstr]()
  File "/usr/local/lib/python2.7/site-packages/salt/fileserver/roots.py", line 176, in update
    .format(mtime_map_path, line))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 70: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/local/bin/salt-ssh", line 10, in <module>
    salt_ssh()
  File "/usr/local/lib/python2.7/site-packages/salt/scripts.py", line 420, in salt_ssh
    client.run()
  File "/usr/local/lib/python2.7/site-packages/salt/cli/ssh.py", line 24, in run
    ssh = salt.client.ssh.SSH(self.config)
  File "/usr/local/lib/python2.7/site-packages/salt/client/ssh/__init__.py", line 326, in __init__
    self.fsclient = salt.fileclient.FSClient(self.opts)
  File "/usr/local/lib/python2.7/site-packages/salt/fileclient.py", line 1401, in __init__
    self.channel = salt.fileserver.FSChan(opts)
  File "/usr/local/lib/python2.7/site-packages/salt/fileserver/__init__.py", line 836, in __init__
    self.fs.update()
  File "/usr/local/lib/python2.7/site-packages/salt/fileserver/__init__.py", line 471, in update
    self.servers[fstr]()
  File "/usr/local/lib/python2.7/site-packages/salt/fileserver/roots.py", line 176, in update
    .format(mtime_map_path, line))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 70: ordinal not in range(128)

@lichtamberg That code is does not match 2018.3, we don't use a .format() there anymore. Can you undo whatever modifications you had made to the code?

The fix above should only be applied to version before 2018.3. If 2018.3 does have an issue (most likely it would be PY2), it would be a different fix.

2018.3 should not have the same issue, our logging handler normalizes the message string and all string args passed to it to unicode before doing the string replacement and logging the message. This is the reason for not using .format() anymore, it does the string formatting immediately and we have no way of automagically normalizing the input to it like we do in the log handler when %s-style string replacement is used.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

Was this page helpful?
0 / 5 - 0 ratings