Skip to content

Remove StrictLink to match OPDS 2.0 spec (PP-3842)#3137

Open
jonathangreen wants to merge 3 commits intomainfrom
chore/remove-strict-link
Open

Remove StrictLink to match OPDS 2.0 spec (PP-3842)#3137
jonathangreen wants to merge 3 commits intomainfrom
chore/remove-strict-link

Conversation

@jonathangreen
Copy link
Member

@jonathangreen jonathangreen commented Mar 13, 2026

Description

Remove the StrictLink class from the OPDS pydantic models and replace all usages with the existing opds2.Link class, which has rel and type as optional fields matching the OPDS 2.0 spec.

StrictLink required both rel and type to be present on every link, but the OPDS 2.0 spec (via the Readium WebPub Manifest link schema) only requires href. This caused parsing failures when external feeds provided spec-compliant links without rel or type.

Changes:

  • Delete StrictLink class from opds2.py
  • Replace StrictLink with Link in all model field type annotations (publications, feeds, groups, ODL licenses)
  • Update serializer type annotations and rename _strict_link() helper to _link()
  • Update extractor type hint for _extract_opds2_formats
  • Add tests confirming links without rel/type are accepted

Not changed:

  • Collection-level validators (validate_self_link, validate_acquisition_link, License.validate_links) — these enforce spec requirements at the collection level (e.g., "feed must contain a self link") via CompactCollection.get() and are unaffected by this change.

Motivation and Context

The OPDS 2.0 spec only requires href on links — rel and type are optional. Our StrictLink was stricter than the spec, causing valid external OPDS feeds to fail parsing when they omitted rel or type on some links. This blocks PP-3842, where authentication documents contain links without rel.

How Has This Been Tested?

  • Updated existing tests to use Link instead of StrictLink
  • Added new TestLinkRelaxedValidation test class with tests confirming:
    • Publications accept links with only href
    • Feeds accept links without type
    • Publication feeds accept links without type

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@jonathangreen jonathangreen marked this pull request as draft March 13, 2026 20:21
The OPDS 2.0 spec (via Readium WebPub Manifest link schema) only
requires href on links — rel and type are optional. StrictLink forced
both to be present, causing parsing failures on spec-compliant feeds.
The parent Link class already has these as optional, and collection-level
validators enforce what the spec actually requires.
@jonathangreen jonathangreen force-pushed the chore/remove-strict-link branch from 7f04a5c to 95164c3 Compare March 13, 2026 20:24
Rename TestLinkRelaxedValidation by moving its tests into the
appropriate model-based test classes (TestPublication, TestFeed,
TestBasePublicationFeed) to follow the project's naming convention.
@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.26%. Comparing base (70374fa) to head (8488bc8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3137      +/-   ##
==========================================
- Coverage   93.26%   93.26%   -0.01%     
==========================================
  Files         493      493              
  Lines       45584    45579       -5     
  Branches     6252     6252              
==========================================
- Hits        42516    42511       -5     
  Misses       1982     1982              
  Partials     1086     1086              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jonathangreen jonathangreen requested review from a team March 13, 2026 23:38
@jonathangreen jonathangreen marked this pull request as ready for review March 13, 2026 23:38
Copy link
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎸🤘🏽

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