Repository navigation
fix: send a tei:// TEI to TEA 0.4.0 endpoints in its urn:tei: form - #48
Conversation
from_tei negotiates TEA 1.0.0 first and fails over to 0.4.0 endpoints, but
sent the tei:// TEI to them verbatim. TEA 0.4.0 defines only the
urn:tei:<type>:<domain>:<identifier> form, so a 0.4.0 server answered 400
("Invalid TEI format") and discovery stopped: tea-cli discover with the
README's tei:// example failed against trust.sbomify.com, which serves
0.4.0 only.
When the endpoint being tried is 0.4.0 (client.is_legacy), _connect now
sends the TEI's legacy form: a purl identifier is decoded from Base64URL to
the PURL, other identifiers are kept byte for byte (percent-escapes are
neither added nor removed). A TEI whose type 0.4.0 does not define, or a
purl TEI that does not carry a PURL, has no legacy form, so that endpoint
is skipped and the next one tried. TEA 1.x endpoints still receive the TEI
verbatim, and TeaClient.discover() is unchanged.
Two CLI tests expected the old behaviour (and mocked a HEAD probe from_tei
no longer sends); they now expect the URN form.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
CodeQL flags "host" in url as incomplete URL sanitization. Compare urlsplit(url).hostname instead, which is also the stricter assertion.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Problem.
TeaClient.from_tei(andtea-cli discover/inspect/ TEIdownloadwithout--base-url) negotiates TEA 1.0.0 first, then fails over to 0.4.0 endpoints. It sent atei://TEI to a 0.4.0 endpoint verbatim, but TEA 0.4.0 defines only theurn:tei:<type>:<domain>:<identifier>form. The README's own example therefore fails againsttrust.sbomify.com, which serves 0.4.0 only:Fix. When the endpoint being tried is 0.4.0 (
client.is_legacy),_connectsends the TEI's legacy form (new helperdiscovery._legacy_tei):purlidentifier is decoded from Base64URL to the PURL itself, as 0.4.0 carries it;purlTEI that doesn't carry a PURL) skips that endpoint and fails over to the next one.TEA 1.x endpoints still receive the TEI verbatim, and
TeaClient.discover()is unchanged (it still sends exactly what it is given).Live check against trust.sbomify.com (from this branch):
tei://…/uuid/…now reaches the server asurn:tei:uuid:…and gets a TEA answer (OBJECT_UNKNOWN: the server doesn't index uuid TEIs) instead of the 400.tei://trust.sbomify.com/purl/<Base64URL of pkg:github/sbomify/sbomify>now resolves and lists sbomify's product releases.Tests. New
TestFromTeicases: uuid, purl (Base64URL decoded) and percent-escaped hash TEIs reach a 0.4.0 endpoint in URN form; on a mixed.well-knownthe 1.0.0 endpoint getstei://and the 0.4.0 fallback gets the URN; TEIs with no 0.4.0 form skip the endpoint without a request. Two CLI tests expected the old verbatim behaviour (and mocked a HEAD probefrom_teino longer sends); they now expect the URN form. 1203 passed, 95% coverage (client.py100%); ruff and mypy clean.Docs. README (Discovery, Upgrading),
docs/cli.md(discover TEI argument), CLAUDE.md (failover note) and thefrom_teidocstring. Touches only lines #46 leaves alone; a trial merge with #46 is clean.