Skip to content

git.latest UnboundLocalError: local variable 'desired_upstream' referenced before assignmen #32260

Closed

Description

@asyncmind0

Description of Issue/Question

 An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1626, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1492, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/states/git.py", line 630, in latest
                  desired_upstream,
              UnboundLocalError: local variable 'desired_upstream' referenced before assignment

Setup

git.latest called with nonexistant rev

Steps to Reproduce Issue

(Include debug logs if possible and relevant.)

Versions Report

(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)

Salt Version:
Salt: 2016.3.0-291-gdcfee8e

Dependency Versions:
Jinja2: 2.8
M2Crypto: Not Installed
Mako: Not Installed
PyYAML: 3.11
PyZMQ: 15.2.0
Python: 2.7.9 (default, Mar 1 2015, 12:57:24)
RAET: Not Installed
Tornado: 4.3
ZMQ: 4.1.2
cffi: 1.5.2
cherrypy: 5.1.0
dateutil: 2.2
gitdb: 0.5.4
gitpython: 0.3.2 RC1
ioflo: Not Installed
libgit2: 0.24.0
libnacl: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.7
mysql-python: 1.2.3
pycparser: 2.14
pycrypto: 2.6.1
pygit2: 0.24.0
python-gnupg: Not Installed
smmap: 0.8.2
timelib: Not Installed

System Versions:
dist: debian 8.3
machine: x86_64
release: 3.16.0-4-amd64
system: Linux
version: debian 8.3

Activity

  1. added
    bug
    severity-medium
    P2
    Platform
    on Mar 31, 2016
  2. added this to the Approved milestone on Mar 31, 2016
  3. jfindlay commented on Mar 31, 2016

    @jfindlay
    Contributor

    @jagguli, thanks for reporting.

  4. ronnix commented on Apr 7, 2016

    @ronnix
    Contributor

    FYI, I ran into this error today too.

    Salt Version:
               Salt: 2015.8.8.2
    
    Dependency Versions:
             Jinja2: 2.7.2
           M2Crypto: Not Installed
               Mako: 0.9.1
             PyYAML: 3.10
              PyZMQ: 14.0.1
             Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
               RAET: Not Installed
            Tornado: 4.2.1
                ZMQ: 4.0.4
               cffi: Not Installed
           cherrypy: Not Installed
           dateutil: 1.5
              gitdb: 0.5.4
          gitpython: 0.3.2 RC1
              ioflo: Not Installed
            libgit2: Not Installed
            libnacl: Not Installed
       msgpack-pure: Not Installed
     msgpack-python: 0.3.0
       mysql-python: 1.2.3
          pycparser: Not Installed
           pycrypto: 2.6.1
             pygit2: Not Installed
       python-gnupg: Not Installed
              smmap: 0.8.2
            timelib: Not Installed
    
    System Versions:
               dist: Ubuntu 14.04 trusty
            machine: x86_64
            release: 3.13.0-83-generic
             system: Ubuntu 14.04 trusty
    
  5. redmcg commented on Apr 13, 2016

    @redmcg

    I ran in to this too. My traceback is a little different though - so may not be the exact same issue.

    I ran in to this when trying to clone an empty repository. I fixed it with a simple one line change:

    diff --git a/salt/states/git.py b/salt/states/git.py
    index d86e364..ba4185d 100644
    --- a/salt/states/git.py
    +++ b/salt/states/git.py
    @@ -576,6 +576,7 @@ def latest(name,
                     # Empty remote repo
                     remote_rev = None
                     remote_rev_type = None
    +                desired_upstream = None
             elif 'refs/heads/' + rev in all_remote_refs:
                 remote_rev = all_remote_refs['refs/heads/' + rev]
                 desired_upstream = '/'.join((remote, rev))
    

    Although this still results in a warning - so I'm still not sure this is the desired result for this scenario.

    My traceback is:

    An exception occurred in this state: Traceback (most recent call last):
                    File "/usr/lib/python2.6/site-packages/salt/state.py", line 1626, in call
                      **cdata['kwargs'])
                    File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1492, in wrapper
                      return f(*args, **kwargs)
                    File "/usr/lib64/python2.6/contextlib.py", line 34, in __exit__
                      self.gen.throw(type, value, traceback)
                    File "/usr/lib/python2.6/site-packages/salt/utils/context.py", line 42, in func_globals_inject
                      yield
                    File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1492, in wrapper
                      return f(*args, **kwargs)
                    File "/usr/lib/python2.6/site-packages/salt/states/git.py", line 630, in latest
                      desired_upstream,
                  UnboundLocalError: local variable 'desired_upstream' referenced before assignment
    

    Version information:

        Salt Version:
                   Salt: 2015.8.8.2
    
        Dependency Versions:
                 Jinja2: unknown
               M2Crypto: Not Installed
                   Mako: Not Installed
                 PyYAML: 3.11
                  PyZMQ: 14.5.0
                 Python: 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
                   RAET: Not Installed
                Tornado: 4.2.1
                    ZMQ: 4.0.5
                   cffi: Not Installed
               cherrypy: Not Installed
               dateutil: 1.4.1
                  gitdb: Not Installed
              gitpython: Not Installed
                  ioflo: Not Installed
                libgit2: 0.20.0
                libnacl: Not Installed
           msgpack-pure: Not Installed
         msgpack-python: 0.4.6
           mysql-python: Not Installed
              pycparser: Not Installed
               pycrypto: 2.6.1
                 pygit2: 0.20.3
           python-gnupg: Not Installed
                  smmap: Not Installed
                timelib: Not Installed
    
        System Versions:
                   dist: centos 6.7 Final
                machine: x86_64
                release: 2.6.32-573.22.1.el6.x86_64
                 system: CentOS 6.7 Final
    
  6. mafrosis commented on Apr 18, 2016

    @mafrosis
    Contributor

    I have also seen this one! I'm happy to run some diagnostic if it would be considered useful.

  7. added
    P1
    and removed
    P2
    on Apr 18, 2016
  8. codekoala commented on May 13, 2016

    @codekoala
    Contributor

    I just hit this bug. We were trying to clone a repo that's mounted as a Vagrant shared folder. I had freshly cloned the repo to my Vagrant host, and the repo was on the master branch. The state was trying to clone the develop branch from the repo on the host to some location in the VM. That's when I encountered the traceback. As soon as I checked out the develop branch on the host, this error went away.

  9. jfindlay commented on May 13, 2016

    @jfindlay
    Contributor
  10. AndreiPashkin commented on May 17, 2016

    @AndreiPashkin
    Contributor

    Also ran into this. In my case I passed non-existent tag as a revision of a remote repo.

    An exception occurred in this state: Traceback (most recent call last):
      File "/tmp/.b5980d/py2/salt/state.py", line 1703, in call
        **cdata['kwargs'])
      File "/tmp/.b5980d/py2/salt/loader.py", line 1649, in wrapper
        return f(*args, **kwargs)
      File "/tmp/.b5980d/py2/salt/states/git.py", line 659, in latest
        desired_upstream,
    UnboundLocalError: local variable 'desired_upstream' referenced before assignment
    
    $ salt-ssh --versions-report
    Salt Version:
               Salt: 2016.3.0rc2
    
    Dependency Versions:
             Jinja2: 2.7.2
           M2Crypto: 0.21.1
               Mako: 0.9.1
             PyYAML: 3.10
              PyZMQ: 14.0.1
             Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
               RAET: Not Installed
            Tornado: 4.3
                ZMQ: 4.0.4
               cffi: Not Installed
           cherrypy: Not Installed
           dateutil: Not Installed
              gitdb: Not Installed
          gitpython: Not Installed
              ioflo: Not Installed
            libgit2: Not Installed
            libnacl: Not Installed
       msgpack-pure: Not Installed
     msgpack-python: 0.3.0
       mysql-python: Not Installed
          pycparser: Not Installed
           pycrypto: 2.6.1
             pygit2: Not Installed
       python-gnupg: Not Installed
              smmap: Not Installed
            timelib: Not Installed
    
    System Versions:
               dist: Ubuntu 14.04 trusty
            machine: x86_64
            release: 3.13.0-74-generic
             system: Linux
            version: Ubuntu 14.04 trusty
    
  11. added a commit that references this issue on May 18, 2016
    263c7fb
  12. modified the milestones: C 10, Approved on May 18, 2016
  13. self-assigned this
    on May 18, 2016
  14. terminalmage commented on May 18, 2016

    @terminalmage
    Contributor

    Fixed in #33340.

  15. added a commit that references this issue on May 19, 2016
    d85096c
  16. added a commit that references this issue on May 20, 2016
    336fbb0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1PlatformState-Modulebugseverity-medium

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions