CLARIN-DSpace v9/Port #1415 (fix the causes of the REST self link console warnings) to the v9 base - #1494
Merged
Merged
Conversation
…nsole warnings ensureSelfLink() stripped embed params from the requested url only, so every request that embeds a subresource compared a url the frontend had normalised against a self link the API had not, and reported a mismatch it had created itself. The API also percent decodes values it has no reason to escape - ':' and '/' are legal in a query component - which looked like another difference. Both sides are now brought to the same form before the comparison: embed params stripped, values percent decoded (urlPartsDiffer, decodeUrlParts, isUnexpectedSelfLink). A difference in an actual value still warns. The second cause is the call sites that asked for 9999 / 10000 / 1000 elements to mean "everything". Spring Data REST caps a page at spring.data.rest.max-page-size, which DSpace leaves at its default of 1000, so those requests never returned more than 1000 rows anyway - they only made the request claim something the API does not honour and left the self link legitimately different from the requested url. MAX_PAGE_SIZE is added next to FindListOptions and used wherever a caller needs everything. The condition that rewrites _links.self is untouched, so the url a response is cached under stays exactly as it was; only whether we warn changes. Adds the first spec this service has had: 17 cases covering both what is now tolerated and what still has to warn. v9 notes: - The text is the 9.3-native original (customer/jcu ca40c3b), which is the same change already formatted for the v9 eslint import rules. registry.service.ts was resolved by hand to keep the CLARIN MetadataBitstreamDataService import. - The six CLARIN-only call sites were hand-applied from d0897c2: clarin-zip-download-page, clarin-all-licenses-page, item-license-mapper, clarin-item-versions-field, clarin-item-box-view, section-license. The #1400 (ROR) and #1396 (route-aware submission PATCH) hunks in the last two files are untouched. - Two call sites exist only on v9 and therefore only in the jcu commit: filtered-items.component.ts (4 x 10000; the file does not exist on dtq-dev) and relationship-type-data.service.ts (dtq-dev still pages it with elementsPerPage 20). - browse-by-geospatial-data.component.ts is deliberately left alone: its 99999 is a Discovery facet limit, not a Spring Data REST page size. Card FE-06 (tranche T1). Source: d0897c2 (dtq-dev PR #1415) Adapted-from: ca40c3b (customer/jcu PR #1440) Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
What
Port of dtq-dev PR #1415 (
d0897c2af7) to the v9 base — card FE-06 (tranche T1) of thedtq-dev→dtq-dev-9-basesync.Removes the bogus
self link doesn't matchconsole warnings, and stops asking the REST API forpage sizes it does not honour.
Why
ensureSelfLink()stripped embed params from the requested url only, so any request embedding asubresource compared a url the frontend had normalised against a self link the API had not — and
reported a mismatch it had created itself. The API additionally percent-decodes
:and/, whichare legal in a query component, which looked like a further difference.
The second cause is the call sites asking for
9999/10000/1000elements to mean"everything". Spring Data REST caps a page at
spring.data.rest.max-page-size(DSpace leaves thedefault 1000), so those requests never returned more than 1000 rows — they only made the request
claim something the API does not honour, leaving the self link legitimately different from the
requested url.
Changes
urlPartsDiffer,decodeUrlParts,isUnexpectedSelfLink); a difference in an actual value still warnsMAX_PAGE_SIZEnext toFindListOptions, used by every "give me everything" call site(15 files;
9999|10000|1000literals insrc/appgo 15 → 0)_links.selfis untouched — the url a response is cached under isunchanged; only whether we warn changes
still warn
v9 adaptations
The text is the 9.3-native original (
customer/jcu ca40c3b9c2, jcu PR #1440) — the same changealready formatted for the v9 eslint import rules.
registry.service.tswas resolved by hand to keepthe CLARIN
MetadataBitstreamDataServiceimport. The six CLARIN-only call sites were hand-appliedfrom
d0897c2af7; the #1400 (ROR) and #1396 (route-aware submission PATCH) hunks inclarin-item-box-view.component.tsandsection-license.component.tsare untouched.Two call sites exist only on v9 and therefore only in the jcu commit —
filtered-items.component.ts(4 × 10000; the file does not exist on
dtq-dev) andrelationship-type-data.service.ts(dtq-devstill pages it with
elementsPerPage: 20).browse-by-geospatial-data.component.tsis deliberatelyleft alone: its
99999is a Discovery facet limit, not a Spring Data REST page size.Testing
Local gates (Windows, Node 20.19.0):
Acceptance greps:
MAX_PAGE_SIZE = 1000→ 1;urlPartsDiffer|decodeUrlParts→ 2; files usingMAX_PAGE_SIZE→ 15; magic9999|10000|1000literals insrc/app→ 0 (was 15);_links.selfrewrite unchanged vs
dspace-9.3→ 0 diff.Sync guards: X1 none of the 15 touched files is byte-identical with
dspace-9.3on the head(six of them were, on the base — this port is what takes them off that list). X6
clarin*.spec.tscount unchanged at 5, no removed
cy./expect(incypress/. X5b orphan/fork-only i18n countsidentical to the base (no json5 touched).
Two environmental caveats, both proven pre-existing by re-running on the untouched base:
npm run test:lint:nobuildis 8/169 red (Windows backslash paths inlint/test/fixture, nothingunder
lint/is touched — CI on Linux is the gate), andcheck-circ-depscannot run throughcmd.exe, so the identical
npx madgeinvocation was run from Git Bash.[live]acceptance criteria are verified after merge and deploy on dev-6:8603, per the syncacceptance document.
Notes for the reviewer
once this merges.
d0897c2af7(dtq-dev PR Fix the causes of the REST self link console warnings #1415) · adapted fromca40c3b9c2(customer/jcu PR Fix the causes of the REST self link console warnings #1440).🤖 Generated with Claude Code