Skip to content

fix(io/sefaria): use 'hebrew' language token in API URLs (0.3.1)#15

Merged
bsesic merged 1 commit into
developfrom
bugfix/sefaria-hebrew-url
Jun 17, 2026
Merged

fix(io/sefaria): use 'hebrew' language token in API URLs (0.3.1)#15
bsesic merged 1 commit into
developfrom
bugfix/sefaria-hebrew-url

Conversation

@bsesic

@bsesic bsesic commented Jun 17, 2026

Copy link
Copy Markdown
Owner

`tracealign.io.sefaria._build_url` constructed query strings with
`?version=he|<title>`. Sefaria's v3 API expects the full language name
(`?version=hebrew|<title>`) and silently returns an empty `versions`
array otherwise, which trips `_select_version`'s 'response has no
versions' error when the importer is exercised against the live API.

This bug shipped in 0.3.0 because every existing test mocks `_fetch_json`
and never exercises the URL construction path. Added two URL-builder
tests that pin the language token to `hebrew` and reject the ISO-code
form.

Discovered while building the Mishna Avot demo in `tracealign-demos`;
the demo loaded the importer against live Sefaria for the first time and
hit the bug immediately.

Test plan

  • `pytest -q` → 194 passed (192 baseline + 2 new URL-builder tests)
  • `flake8 src/ tests/` → no output
  • CI passes on Python 3.10/3.11/3.12
  • Manual: `sefaria.load_segments('Pirkei Avot 1', version='Mishnah, ed. Romm, Vilna 1913', seq_label='Vilna')` returns tokens against live Sefaria (verified locally)

Release plan

Patch release 0.3.1 immediately after this PR merges.

Sefaria's v3 API expects the version-query language as a full name
(e.g. 'hebrew', 'english', 'french'), not the ISO code. Passing 'he|<title>'
silently returns an empty 'versions' array with warning code 102, which then
trips _select_version's 'response has no versions' ValueError when the
importer is exercised against live Sefaria.

The unit tests caught nothing because every existing test mocks _fetch_json
and never exercises the URL construction path against the real API. Add two
URL-builder tests that pin the language token to 'hebrew' and reject the
ISO-code form.

Discovered while building the Mishna Avot demo in tracealign-demos.
@bsesic bsesic merged commit e20ef47 into develop Jun 17, 2026
3 checks passed
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