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

fix: Typo alt_name -> alt_names #1854

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

coldkick2
Copy link

@coldkick2 coldkick2 commented Jan 15, 2025

When editing a place the application can crash if the alt_name is not set.

Steps to reproduce:

  1. Create a person
  2. Add a new event (Birth for example)
  3. Assign a new place
  4. Go to Places tab
  5. Right click > Edit the existing location
  6. Click Share
  7. The application will crash with an error similar to below
2025-01-15 12:24:43.096: ERROR: grampsapp.py: line 188: Unhandled exception
Traceback (most recent call last):
  File "/home/coldkick/code/Gramps/gramps/gui/editors/displaytabs/placerefembedlist.py", line 168, in share_button_clicked
    sel = SelectPlace(
        self.dbstate, self.uistate, self.track, skip=self.get_skip_list(self.handle)
    )
  File "/home/coldkick/code/Gramps/gramps/gui/selectors/baseselector.py", line 149, in __init__
    self.build_tree()
    ~~~~~~~~~~~~~~~^^
  File "/home/coldkick/code/Gramps/gramps/gui/selectors/baseselector.py", line 312, in build_tree
    self.model = self.get_model_class()(
                 ~~~~~~~~~~~~~~~~~~~~~~^
        self.db,
        ^^^^^^^^
    ...<5 lines>...
        search=filter_info,
        ^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/coldkick/code/Gramps/gramps/gui/views/treemodels/placemodel.py", line 322, in __init__
    TreeBaseModel.__init__(
    ~~~~~~~~~~~~~~~~~~~~~~^
        self,
        ^^^^^
    ...<8 lines>...
        group_can_have_handle=True,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/coldkick/code/Gramps/gramps/gui/views/treemodels/treebasemodel.py", line 368, in __init__
    self.rebuild_data(self.current_filter, skip=skip)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/coldkick/code/Gramps/gramps/gui/views/treemodels/treebasemodel.py", line 526, in rebuild_data
    self._build_data(self.current_filter, None, skip)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/coldkick/code/Gramps/gramps/gui/views/treemodels/treebasemodel.py", line 550, in _rebuild_search
    self.__rebuild_search(dfilter, skip, items, self.gen_cursor, self.add_row)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/coldkick/code/Gramps/gramps/gui/views/treemodels/treebasemodel.py", line 577, in __rebuild_search
    handle in skip or (dfilter and not dfilter.match(handle, self.db))
                                       ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/coldkick/code/Gramps/gramps/gen/filters/_searchfilter.py", line 33, in match
    return self.invert ^ (self.func(handle).upper().find(self.text) != -1)
                          ~~~~~~~~~^^^^^^^^
  File "/home/coldkick/code/Gramps/gramps/gui/views/treemodels/treebasemodel.py", line 472, in <lambda>
    func = lambda x: self._get_value(x, col, secondary=False) or ""
                     ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/coldkick/code/Gramps/gramps/gui/views/treemodels/treebasemodel.py", line 991, in _get_value
    value = self.fmap[col](data)
  File "/home/coldkick/code/Gramps/gramps/gui/views/treemodels/placemodel.py", line 142, in search_name
    [data["name"]["value"]] + [name["value"] for name in data["alt_name"]]
                                                         ~~~~^^^^^^^^^^^^
KeyError: 'alt_name'

An alternative solution would be to ensure the alt_name field always exists, but it is unclear to me why it doesn't exist in this usage pattern, and this protection would ensure it doesn't break in the same way again in the future.

@Nick-Hall Nick-Hall added the bug label Jan 15, 2025
@coldkick2
Copy link
Author

This issue does not seem to occur if creating the places from the Places View

@Nick-Hall
Copy link
Member

I can't reproduce this. I don't understand step 4 - "Go to Places tab". What places tab do you mean?

If I create a new place from within the event editor, it seems to create the "alt_names" entry correctly.

@coldkick2
Copy link
Author

I'll do a screen recording tonight, from start to end. I'll also do another pull incase it has been resolved in the last week.

Cheers

@hgohel
Copy link
Member

hgohel commented Jan 26, 2025

@coldkick2 Does this bug affect Gramps 5.2.x release, or only the master branch?

@coldkick2
Copy link
Author

Only master, it did not affect the release branch when I tested

@Nick-Hall
Copy link
Member

@dsblank Can you reproduce this problem?

@dsblank
Copy link
Member

dsblank commented Jan 29, 2025

Yes, this is a simple typo: "alt_name" should be "alt_names". @coldkick2 do you want to fix it here?

@coldkick2
Copy link
Author

Sorry, I've been very busy. It's always something small and simple. My arch install also is crashing on boot now, so if I can't get that resolved quickly I'll close my ticket so the fix can go in on another branch.

@dsblank dsblank changed the title fix: Alt Name being unset causes KeyError Crash fix: Typo alt_name -> alt_names Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants