Remove StrictLink to match OPDS 2.0 spec (PP-3842)#3137
Open
jonathangreen wants to merge 3 commits intomainfrom
Open
Remove StrictLink to match OPDS 2.0 spec (PP-3842)#3137jonathangreen wants to merge 3 commits intomainfrom
jonathangreen wants to merge 3 commits intomainfrom
Conversation
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.
7f04a5c to
95164c3
Compare
Rename TestLinkRelaxedValidation by moving its tests into the appropriate model-based test classes (TestPublication, TestFeed, TestBasePublicationFeed) to follow the project's naming convention.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Remove the
StrictLinkclass from the OPDS pydantic models and replace all usages with the existingopds2.Linkclass, which hasrelandtypeas optional fields matching the OPDS 2.0 spec.StrictLinkrequired bothrelandtypeto be present on every link, but the OPDS 2.0 spec (via the Readium WebPub Manifest link schema) only requireshref. This caused parsing failures when external feeds provided spec-compliant links withoutrelortype.Changes:
StrictLinkclass fromopds2.pyStrictLinkwithLinkin all model field type annotations (publications, feeds, groups, ODL licenses)_strict_link()helper to_link()_extract_opds2_formatsrel/typeare acceptedNot changed:
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") viaCompactCollection.get()and are unaffected by this change.Motivation and Context
The OPDS 2.0 spec only requires
hrefon links —relandtypeare optional. OurStrictLinkwas stricter than the spec, causing valid external OPDS feeds to fail parsing when they omittedrelortypeon some links. This blocks PP-3842, where authentication documents contain links withoutrel.How Has This Been Tested?
Linkinstead ofStrictLinkTestLinkRelaxedValidationtest class with tests confirming:hreftypetypeChecklist