#8618 fix git thread-safety issues

unreleased
review
None
General
nobody
2026-09-09
2026-08-25
No

Got this when we were taking a lots of simultaneous requests. Weird error showing template code from a repo, where a SHA was expected.

   File '/var/local/allura/Allura/allura/controllers/repository.py', line 906 in index
     return self.raw()
   File '/var/local/allura/Allura/allura/controllers/repository.py', line 942 in raw
     return iter(self._blob)
   File '/var/local/allura/Allura/allura/model/repository.py', line 1615 in __iter__
     return iter(self.open())
   File '/var/local/allura/Allura/allura/model/repository.py', line 1612 in open
     return self.repo.open_blob(self)
   File '/var/local/allura/Allura/allura/model/repository.py', line 487 in open_blob
     return self._impl.open_blob(blob)
   File '/var/local/allura/ForgeGit/forgegit/model/git_repo.py', line 500 in open_blob
     self._object(blob._id).data_stream)
   File '/var/local/env-allura/lib/python3.11/site-packages/git/objects/base.py', line 201 in data_stream
     return self.repo.odb.stream(self.binsha)
   File '/var/local/env-allura/lib/python3.11/site-packages/git/db.py', line 50 in stream
     hexsha, typename, size, stream = self._git.stream_object_data(bin_to_hex(binsha))
   File '/var/local/env-allura/lib/python3.11/site-packages/git/cmd.py', line 1896 in stream_object_data
     hexsha, typename, size = self.__get_object_header(cmd, ref)
   File '/var/local/env-allura/lib/python3.11/site-packages/git/cmd.py', line 1853 in __get_object_header
     return self._parse_object_header(cmd.stdout.readline())
   File '/var/local/env-allura/lib/python3.11/site-packages/git/cmd.py', line 1814 in _parse_object_header
     raise ValueError("SHA %s could not be resolved, git returned: %r" % (tokens[0], header_line.strip()))
   ValueError: SHA b'{%' could not be resolved, git returned: b'{% extends g.theme.master %}'

Related

Commit: [17b408]
Commit: [281c0b]
Commit: [45090e]

Discussion

  • Dave Brondsema

    Dave Brondsema - 2026-08-25
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,7 +1,7 @@
     Got this when we were taking a lots of simultaneous requests.  Weird error showing template code from a repo, where a SHA was expected. 
    
     ```
    
    -  '/var/local/allura/Allura/allura/controllers/repository.py', line 906 in index
    +   File '/var/local/allura/Allura/allura/controllers/repository.py', line 906 in index
          return self.raw()
        File '/var/local/allura/Allura/allura/controllers/repository.py', line 942 in raw
          return iter(self._blob)
    @@ -23,4 +23,5 @@
          return self._parse_object_header(cmd.stdout.readline())
        File '/var/local/env-allura/lib/python3.11/site-packages/git/cmd.py', line 1814 in _parse_object_header
          raise ValueError("SHA %s could not be resolved, git returned: %r" % (tokens[0], header_line.strip()))
    -   ValueError: SHA b'{%' could not be resolved, git returned: b'{% extends g.theme.master %}'```
    +   ValueError: SHA b'{%' could not be resolved, git returned: b'{% extends g.theme.master %}'
    +```
    
     
  • Dave Brondsema

    Dave Brondsema - 2026-09-09
    • status: open --> review
     
  • Dave Brondsema

    Dave Brondsema - 2026-09-09

    fix on db/8618-cat-file Ended up being re-use after streaming, in same thread, not different threads

     

Log in to post a comment.