Narrative Web Report Error cannot access local variable 'bletter' where it is not associated with a value

Got the following error anybody got any ideas as to where I should look to find out the cause suspect something in my tree not a bug
phil

62156: ERROR: _reportdialog.py: line 801: Failed to run report.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/gramps/gui/plug/report/_reportdialog.py", line 760, in report
    my_report.write_report()
  File "/usr/lib/python3/dist-packages/gramps/plugins/webreport/narrativeweb.py", line 538, in write_report
    self.tab["Person"].display_pages(the_lang, the_title)
  File "/usr/lib/python3/dist-packages/gramps/plugins/webreport/person.py", line 181, in display_pages
    self.individuallistpage(
  File "/usr/lib/python3/dist-packages/gramps/plugins/webreport/person.py", line 557, in individuallistpage
    max_rows = max_letter_rows[bletter]
                               ^^^^^^^
UnboundLocalError: cannot access local variable 'bletter' where it is not associated with a value

GRAMPS: 5.2.4
Python: 3.11.2
BSDDB: 6.2.9 (5, 3, 28)
sqlite: 3.40.1 (2.6.0)
LANG: en_GB.UTF-8
OS: Linux
Distribution: 6.1.0-30-amd64

It looks like this may be related to pull request #1896 - “New indexes for big databases in the narrative web report”.

Thanks Nick

My Family Tree is approx 18000 individuals, tried increasing the value
for the index from 500 to 2000 made no difference.
Will spend some more time on this and get back to you
phil

1 Like

Make a bug request for this problem.

We have a problem here. Did you modified the sources ?

The following instruction does not exist at line 557:

max_rows = max_letter_rows[bletter]

Serge

I run 2 PC’s a Pi5 running Bookworm and an i5 running LMDE6 both have
Version 5.2.4 with your mod for incl roles.
Both do have that line as described at line 557.
Neither has been updated or changed in the last 3 months.

I have subsequently run the report on the Pi using a simplified tree
with no problem.

I need to retrace all my steps to reproduce the error will get back to you
phil

Serge

Apologies for delayed response.
My usual working method is to create a backup on my LMDE PC and store it
on my NAS, I then import it to my Pi5.
For some reason (senior moment) I had copied my grampsdb folder on my
LMDE PC and then pasted this into my Pi5. It is this version that brings
up the error. So must be the difference in setup between LMDE and
Bookworm that causes the issue which I have no inclination or desire to
investigate further.
Please do not worry about this further made a note to self only do the
“import” in future.
phil

You should apply a patch for this. It was commit a8885d5855d901f833064d1b69ec45f7b8cfe79d

1 Like

Two problems with that commit for me

  1. It is for Ver 6 not explicitly for 5.2.4
    2)“Fix narrative web report crash with empty an database.” My database is fully functional and not empty as far as I am aware
    phil

This is the solution for you. You must adapt this patch to 5.2.4.

I am feeling particularly dense today but could you point me in the direction of the original report that caused you to make this patch.
The fault occurred as a result of my own actions of copying and pasting a database rather than importing and when using the importing route I do not have an error, but the copying and pasting route gives an error however this database is perfectly usable other than for the Narrative Web Report.
Thank you for confirming that the patch is suitable for 5.2.4
phil

Tye linked commit above says that it was merged into the 6.0 (for rc2) maintenance branch in February 2025:

  • PR1951 Narrative web: crash with empty database.

In response to:

  • 13619: Error message when creating a narrative web report

This was one way to create the bug.
I can say you can safely apply the patch I proposed.
This patch only remove the max_rows variable which is the cause of your problem.
You can see what it do with the command:
git show a8885d5855d901f833064d1b69ec45f7b8cfe79d

1 Like

I think I would like to close this off. Firstly by thanking Serge, Nick
and Brian for their assistance/forbearance for trying to resolve a
situation of my own creation (should have known better).
The current situation is that I have applied Serge’s latest commit with
no issues on existing or imported databases.
The database I copied and pasted now does not show an error when running
as expected but the final report has no contents whatsoever yet the db
is clearly populated.
phil

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.