Review Board Ticket #4969: interdiff sometimes fails with a variable used before assignment

7 views
Skip to first unread message

Gary Kramlich

unread,
May 3, 2022, 12:36:43 AM5/3/22
to Gary Kramlich, reviewboa...@googlegroups.com
To reply, visit https://hellosplat.com/s/beanbag/tickets/4969/

New ticket #4969 by grim

For Beanbag, Inc. Review Board

interdiff sometimes fails with a variable used before assignment

What version are you running?

4.0.6

What's the URL of the page containing the problem?

https://reviews.imfreedom.org/r/1293/diff/3-4/

What steps will reproduce the problem?

Not sure actually, but the interdiff was created via hg rebase and the diff is attached.

What is the expected output? What do you see instead?

The diff instead of a python error :-D

What operating system are you using? What browser?

Linux, Chrome/Firefox

Please provide any additional information below.

We've seen this across a number of review requests, it's not a huge deal as it's interdiffs, but would be great it if was working properly.

Also since this was from a rebase, I've provided a diff with just the files failing in the interdiff as well as the entire diff between the final revision and the one that was obsoleted.

New Priority:Medium Type:Defect

David Trowbridge

unread,
May 3, 2022, 11:50:23 AM5/3/22
to David Trowbridge, Gary Kramlich, reviewboa...@googlegroups.com

New update by david

For Beanbag, Inc. Review Board Ticket #4969

The error:

Traceback (most recent call last):
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/views.py", line 447, in get
    response = renderer.render_to_response(request)
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/renderers.py", line 57, in render_to_response
    return HttpResponse(self.render_to_string(request))
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/renderers.py", line 72, in render_to_string
    return cache_memoize(
  File "/venv/lib/python3.8/site-packages/djblets/cache/backend.py", line 312, in cache_memoize
    results = list(cache_memoize_iter(key,
  File "/venv/lib/python3.8/site-packages/djblets/cache/backend.py", line 254, in cache_memoize_iter
    items = items_or_callable()
  File "/venv/lib/python3.8/site-packages/djblets/cache/backend.py", line 313, in <lambda>
    lambda: [lookup_callable()],
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/renderers.py", line 74, in <lambda>
    lambda: self.render_to_string_uncached(request),
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/renderers.py", line 87, in render_to_string_uncached
    populate_diff_chunks([self.diff_file], self.highlighting,
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/diffutils.py", line 1251, in populate_diff_chunks
    chunks = list(generator.get_chunks())
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 996, in get_chunks
    for chunk in super(DiffChunkGenerator, self).get_chunks(cache_key):
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 161, in get_chunks
    chunks = cache_memoize(cache_key,
  File "/venv/lib/python3.8/site-packages/djblets/cache/backend.py", line 312, in cache_memoize
    results = list(cache_memoize_iter(key,
  File "/venv/lib/python3.8/site-packages/djblets/cache/backend.py", line 254, in cache_memoize_iter
    items = items_or_callable()
  File "/venv/lib/python3.8/site-packages/djblets/cache/backend.py", line 313, in <lambda>
    lambda: [lookup_callable()],
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 162, in <lambda>
    lambda: list(self.get_chunks_uncached()),
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 1119, in get_chunks_uncached
    for chunk in self.generate_chunks(old=old,
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 305, in generate_chunks
    lines = [
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 306, in <listcomp>
    self._diff_line(tag, meta, *diff_args)
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 533, in _diff_line
    old_markup, new_markup = self._highlight_indentation(
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 600, in _highlight_indentation
    new_markup = self._wrap_indentation_chars(
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 646, in _wrap_indentation_chars
    serialized, remainder = serializer(indentation, norm_indent_len_diff)
  File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 688, in _serialize_indentation
    return s, chars[j + 1:]
UnboundLocalError: local variable 'j' referenced before assignment

Christian Hammond

unread,
May 4, 2022, 6:33:29 PM5/4/22
to Christian Hammond, Gary Kramlich, reviewboa...@googlegroups.com

New update by chipx86

I looked into this a bit when you reported this to me, and... the cause of that UnboundLocalError is easily fixed, but it shouldn't be hitting that code to begin with unless it'd be in a state where j would be assigned. So there's a real bug with that function, but also something leading to that function being called. Kinda weird. Going to require some investigation.

Reply all
Reply to author
Forward
0 new messages