Skip to content

CalculateEstimatedDates: handle ancestry-loop DatabaseError (bug 0007898) - #7

Closed
eduralph wants to merge 1 commit into
maintenance/gramps60from
fix/calculateestimateddates-gramps-id-7898
Closed

CalculateEstimatedDates: handle ancestry-loop DatabaseError (bug 0007898)#7
eduralph wants to merge 1 commit into
maintenance/gramps60from
fix/calculateestimateddates-gramps-id-7898

Conversation

@eduralph

Copy link
Copy Markdown
Owner

Summary

  • Fixes Gramps bug 0007898: the Calculate Estimated Dates tool crashes the whole run when probably_alive_range raises DatabaseError on a family-tree loop (ancestor or descendant cycle).
  • Wraps each per-person iteration across the three loops (removal, selection, apply) with try/except so a single bad record is logged via LOG.warning and skipped instead of tearing down the tool.
  • Adds outer try/finally blocks so signals are re-enabled and the progress dialog is closed even on unexpected failures, and surfaces a "Skipped N people due to errors" message to the user.
  • Adds unit tests for get_modifier, calc_estimates (happy path + DatabaseError propagation), and .gpr.py registration metadata. The addon module is loaded lazily inside a fixture so collection succeeds even when the GUI stack cannot import.

Test plan

  • python3 -m pytest CalculateEstimatedDates/tests/test_calculate_estimated_dates.py::test_gpr_registration_metadata -v passes locally
  • Full test file passes in the gramps-ci CI container (six lazily-loaded tests skip on this dev machine due to a snap/glibc conflict that crashes Python at C level — unrelated to the fix)
  • Manual verification: run Calculate Estimated Dates on a tree with a known ancestry loop and confirm the tool completes with a "skipped" message rather than crashing

🤖 Generated with Claude Code

…n (bug 0007898)

probably_alive_range raises DatabaseError when it detects loops in
ancestor or descendant chains. Previously this propagated out of the
removal, selection, and apply loops and tore down the entire tool,
leaving signals disabled and the progress dialog stuck open.

Wrap each per-person iteration with try/except so a single bad record
is logged and skipped, and add outer try/finally blocks so signals are
re-enabled and the progress dialog is closed even on unexpected
failures. Surface a "Skipped N people due to errors" message to the
user when any rows were skipped.

Add unit tests covering get_modifier branches, calc_estimates happy
path, DatabaseError propagation from calc_estimates, and .gpr.py
registration metadata. The addon module is loaded lazily inside a
fixture so pytest collection succeeds even when the GUI stack cannot
import.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@eduralph
eduralph force-pushed the fix/calculateestimateddates-gramps-id-7898 branch from 2b168b5 to a2136d7 Compare April 18, 2026 00:08
@eduralph

Copy link
Copy Markdown
Owner Author

Superseded — opening upstream PR against gramps-project/addons-source.

@eduralph eduralph closed this Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant