Skip to content

Add --tree flag for FamilySearch Group tree selection - #82

Open
szabi wants to merge 1 commit into
Linekio:masterfrom
szabi:master
Open

Add --tree flag for FamilySearch Group tree selection#82
szabi wants to merge 1 commit into
Linekio:masterfrom
szabi:master

Conversation

@szabi

@szabi szabi commented Jul 22, 2026

Copy link
Copy Markdown

PR: Add --tree flag for FamilySearch Group tree selection

Summary

  • Adds -T/--tree CLI argument to target a specific FamilySearch Group tree instead of the default main Family Tree
  • Adds uv lock file and tooling configuration (optional — existing pip workflow is unaffected)
  • Bumps requires-python from >=3.7 to >=3.9

The feature

FamilySearch exposes two distinct tree systems: the single shared main Family Tree, and privately-owned user trees, called "Group trees" on the UI (/platform/trees/…). This project previously had no way to target a user tree — the tree selection call had to be manually patched in.

The new flag activates a user tree by POSTing to /platform/trees/current immediately after login, scoping all subsequent API calls to that tree. Omitting the flag leaves behaviour unchanged.

getmyancestors -u user@example.com -p secret -T XXXX-XXXX -o output.ged

Error handling

HTTP status Cause Behaviour
400 Invalid tree ID Log + exit with user-facing message
429 Rate limited Log + sleep + retry
other 4xx/5xx Transient error Log + sleep + retry

Note: 400 is also returned by the API for an invalid bearer token, but since _set_tree is only called after a successful login(), a valid token is guaranteed at that point.

Implementation notes

  • DEFAULT_TREE = "GLOBAL" is defined as a module-level constant in session.py alongside the existing DEFAULT_CLIENT_ID and DEFAULT_REDIRECT_URI constants. The CLI imports it directly, making it the single source of truth for the default value and the --help display.
  • The guard if self._tree and self._tree != DEFAULT_TREE in __init__ ensures no API call is made when the default is used.

uv support

Adds uv.lock and [tool.uv] package = true to pyproject.toml. The package = true flag is required for uv to install the CLI entry points (getmyancestors, mergemyancestors, fstogedcom); without it uv treats the project as a non-package workspace member and skips installation.

Using uv is entirely optional. pip and other tools continue to work as before.


Python version bump (3.7 → 3.9)

The bump was required by uv's dependency resolver. It reflects reality:

  • Python 3.7 has been end-of-life since June 2023
  • Python 3.9 itself reached end-of-life in October 2025

Users on any currently supported Python release (3.10+) are unaffected.


Test plan

  • getmyancestors … -T <valid-tree-id> — downloads from the specified user tree
  • getmyancestors … -T <invalid-id> — exits with a clear error message, no traceback
  • getmyancestors … (no -T) — behaviour identical to before this change
  • uv run getmyancestors — CLI entry point installs and runs correctly

Adds a -T/--tree CLI argument and corresponding Session parameter that
activates a specific FamilySearch user tree at login time, by POSTing to
/platform/trees/current. Without the flag, behaviour is unchanged: the
main shared Family Tree ("GLOBAL") is used.

Error handling follows existing project conventions: HTTP 400 (invalid
tree ID) exits immediately with a user-facing message; HTTP 429 backs off
and retries; other transient errors log and retry. The default value
"GLOBAL" is defined as DEFAULT_TREE in session.py and imported by the
CLI, making it the single source of truth.

Also adds uv tooling support (uv.lock, [tool.uv] package = true in
pyproject.toml). Using uv is optional — pip/other tools continue to work
as before. The package = true flag is required for uv to install the CLI
entry points (getmyancestors, mergemyancestors, fstogedcom).

Bumps requires-python from >=3.7 to >=3.9. The bump was required by
uv's dependency resolver and reflects reality: 3.7 has been end-of-life
since June 2023, and 3.9 itself reached end-of-life in October 2025.
Users on a supported Python release are unaffected.
@Linekio

Linekio commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Hi, is this PR ready for review? One thing I noticed: after the POST /platform/trees/current in _set_tree, the tree ID isn't used anywhere else

@szabi

szabi commented Aug 11, 2026

Copy link
Copy Markdown
Author

Yes, this is ready for review. Indeed, the tree ID is not used anywhere. This is due to an (IMHO strange) design decision by FamilySearch for their API that it's stateful, i.e. once you POST the tree to said endpoint, all future operations (queries, creation, ...) are against that tree for the rest of the session.

Because getmyancestors CLI works in one session, that means it's sufficient to POST at the beginning.

I've also successfully used getmyancestors CLI with my patch, it works confirmed. What I admittedly did not test (nor do I have the capacity to) is your GUI wrapper. (But because of the defaults, I'd assume it works unchanged, it's just that the option to select another tree than the GLOBAL is not exposed on the GUI.

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.

2 participants