Skip to content
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

UnicodeDecodeError in states.file #28524

Closed
bmcorser opened this issue Nov 3, 2015 · 4 comments
Closed

UnicodeDecodeError in states.file #28524

bmcorser opened this issue Nov 3, 2015 · 4 comments
Labels
Bug broken, incorrect, or confusing behavior fixed-pls-verify fix is linked, bug author to confirm fix P3 Priority 3 Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around State-Module
Milestone

Comments

@bmcorser
Copy link
Contributor

bmcorser commented Nov 3, 2015

I have a Runner that is calling state.single with file.recurse to copy files from master to minion. I guess the error is occuring on the minion. But I'm a bit unclear as to what could be causing it. I know the files I'm copying with file.recurse have unicode codepoints in them, but would be surprised if this was causing the issue.

minion-x:
    ----------
    file_|-/opt/deploy_|-/opt/deploy_|-recurse:
        ----------
        __run_num__:
            0
        changes:
            ----------
        comment:
            An exception occurred in this state: Traceback (most recent call last):
              File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1560, in call
                **cdata['kwargs'])
              File "/usr/lib/python2.7/dist-packages/salt/states/file.py", line 2317, in recurse
                src = u'salt://{0}'.format(fn_)
            UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 45: ordinal not in range(128)
        duration:
            8868.469
        name:
            /opt/deploy
        result:
            False
        start_time:
            15:56:11.275353

Versions match; master version:

                  Salt: 2015.5.3
                Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
                Jinja2: 2.7.2
              M2Crypto: 0.21.1
        msgpack-python: 0.3.0
          msgpack-pure: Not Installed
              pycrypto: 2.6.1
               libnacl: Not Installed
                PyYAML: 3.10
                 ioflo: Not Installed
                 PyZMQ: 14.0.1
                  RAET: Not Installed
                   ZMQ: 4.0.4
                  Mako: 0.9.1
               Tornado: Not Installed
 Debian source package: 2015.5.3+ds-1trusty1

Minion version:

salt-minion 2015.5.3 (Lithium)
@bmcorser
Copy link
Contributor Author

bmcorser commented Nov 3, 2015

Ok, it appears that unicode in filenames isn't supported somewhere along the way. If I make a small change to the exception that was getting raised:

diff --git a/usr/lib/python2.7/dist-packages/salt/states/file.py b/file.py
index f3bb0db..491a508 100644
--- a/usr/lib/python2.7/dist-packages/salt/states/file.py
+++ b/file.py
@@ -2313,7 +2313,10 @@ def recurse(name,
             # verify the directory perms if they are set
             manage_directory(dirname)
             vdir.add(dirname)
-        src = u'salt://{0}'.format(fn_)
+        try:
+            src = u'salt://{0}'.format(fn_)
+        except Exception as exc:
+            raise Exception(fn_)
         manage_file(dest, src)

     if include_empty:

Then I can see what's causing the barf in my output:

minion-x:
    ----------
    file_|-/opt/deploy_|-/opt/deploy_|-recurse:
        ----------
        __run_num__:
            0
        changes:
            ----------
        comment:
            An exception occurred in this state: Traceback (most recent call last):
              File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1560, in call
                **cdata['kwargs'])
              File "/usr/lib/python2.7/dist-packages/salt/states/file.py", line 2319, in recurse
                raise Exception(fn_)
            Exception: _tmp/5Lmgtm/some/path/components/pACP-ADRß2.fasta
        duration:
            8880.017
        name:
            /opt/deploy
        result:
            False
        start_time:
            16:14:19.999637

There's a ß character in the filename.

@bmcorser bmcorser changed the title state.single file.recurse barfing on UnicodeDecodeError UnicodeDecodeError in states.file Nov 3, 2015
jfindlay added a commit to jfindlay/salt that referenced this issue Nov 3, 2015
@jfindlay jfindlay added State-Module Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around fixed-pls-verify fix is linked, bug author to confirm fix P3 Priority 3 Platform Relates to OS, containers, platform-based utilities like FS, system based apps labels Nov 3, 2015
@jfindlay jfindlay added this to the Approved milestone Nov 3, 2015
@jfindlay
Copy link
Contributor

jfindlay commented Nov 3, 2015

@bmcorser, thanks for the report. This should be fixed in the pull requests mentioned.

@bmcorser
Copy link
Contributor Author

bmcorser commented Nov 4, 2015

👍 Please close when you're happy

@bmcorser
Copy link
Contributor Author

bmcorser commented Nov 4, 2015

Hmmm just spotted #23271

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior fixed-pls-verify fix is linked, bug author to confirm fix P3 Priority 3 Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around State-Module
Projects
None yet
Development

No branches or pull requests

2 participants