Skip to content

Fix the causes of the REST self link console warnings - #1440

Merged
milanmajchrak merged 2 commits into
customer/jcufrom
fix/862-self-link-embed-mismatch-jcu
Aug 7, 2026
Merged

Fix the causes of the REST self link console warnings#1440
milanmajchrak merged 2 commits into
customer/jcufrom
fix/862-self-link-embed-mismatch-jcu

Conversation

@milanmajchrak

Copy link
Copy Markdown
Collaborator

References

Description

dspace.log fills up with The response for '…' has the self link '…'. These don't match. Two causes,
both fixed here:

  • The comparison stripped embed from one side only. The frontend removes embed params from its
    own url before comparing, but not from the self link the API echoes back — so it reported a
    difference it created itself. Both sides are now normalized the same way (embed stripped, percent
    decoded).
  • Call sites asked for page sizes the API never serves. 9999 / 10000 are silently reduced to
    1000 by Spring Data REST, so the self link legitimately came back different. Those call sites now use
    the new MAX_PAGE_SIZE = 1000. This is not filtered out of the comparison — a reduced page size
    still warns, so the next caller who writes 9999 finds out.

Instructions for Reviewers

The change to ensureSelfLink is warning-only: the outer condition that rewrites _links.self is
unchanged, so caching behaves exactly as before. Only the console.warn gained a second condition.

Page sizes are behaviour-preserving: the API already capped every one of these at 1000
(spring.data.rest.max-page-size, which DSpace leaves at its default — verified: it is set nowhere in
DSpace/DSpace nor in our fork). Requesting 1000 returns the same page as requesting 9999.

Call sites changed (9.3 has more of them than 7.6.5 did):

file was
core/data/bundle-data.service.ts 9999
core/browse/browse.service.ts 9999
core/data/relationship-type-data.service.ts 9999
core/registry/registry.service.ts 10000
item-page/edit-item-page/item-bitstreams/item-bitstreams.service.ts 9999
admin/admin-reports/filtered-items/filtered-items.component.ts 4 × 10000

Deliberately left alone: browse-by-geospatial-data.component.ts sets pageSize = 99999 and
facetLimit = 99999. That is a Discovery facet limit, not a Spring Data REST page size, so it is not
capped at 1000 and lowering it would drop points off the map.

How to test: open an item page, the home page and /browse/title with the console open. Before:
These don't match warnings. After: none.

Checklist

  • My PR is created against the main branch — no: base is customer/jcu, as requested. The
    same fix is already merged into dtq-dev (Fix the causes of the REST self link console warnings #1415).
  • My PR is small in size.
  • My PR passes ESLint — 0 errors on the changed files (5 pre-existing deprecation warnings on
    untouched lines).
  • My PR doesn't introduce circular dependencies.
  • My PR includes Typedoc comments for all new public methods and classes.
  • My PR passes all tests and includes new tests — new
    dspace-rest-response-parsing.service.spec.ts (17 cases, the first spec this service has ever had);
    full suite green.
  • My PR includes details on how to test it.
  • My PR includes screenshots — not applicable, the change is console output only.
  • If my PR includes new libraries/dependencies — none.

Not verified here

The browser before/after (3 warnings → 0) was measured on the dtq-dev version against a local DSpace
9.1 backend. It was not re-run against a 9.3 stack for this branch — the ensureSelfLink logic is
byte-identical between the two branches, but say the word and I'll do the run.

milanmajchrak and others added 2 commits August 7, 2026 12:24
The frontend strips embed params from its own url before comparing it to the self
link the API returns, but not from the self link itself, so it reported a mismatch
it had created. 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. A difference in an actual value still warns.

Only the warning is affected. The condition that rewrites _links.self is unchanged,
so the url a response is cached under stays the same.

Adds the first spec this service has had, 17 cases covering both what is now
tolerated and what still has to warn.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Spring Data REST caps a page at spring.data.rest.max-page-size, which DSpace leaves
at its default of 1000 - it is set nowhere in DSpace/DSpace nor in our fork. So
asking for 9999 or 10000 returns the same 1000 rows it would have returned anyway,
while making the request claim something the API never honours, and leaving the self
link legitimately different from the requested url.

Adds MAX_PAGE_SIZE and uses it wherever a caller needs "everything":

  bundle-data.service.ts                9999
  browse.service.ts                     9999
  relationship-type-data.service.ts     9999
  registry.service.ts                  10000
  item-bitstreams.service.ts            9999
  filtered-items.component.ts     4 x 10000

Same rows returned in every case; only the number in the request changes.

browse-by-geospatial-data.component.ts is left alone on purpose: its 99999 is a
Discovery facet limit, not a Spring Data REST page size, so it is not capped at
1000 and lowering it would drop points off the map.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces noisy REST self-link mismatch warnings by (1) normalizing how requested URLs and API self links are compared (embed params stripped on both sides and percent-decoding applied), and (2) replacing oversized page-size requests (e.g. 9999/10000) with an explicit MAX_PAGE_SIZE = 1000 to align with Spring Data REST’s server-side cap.

Changes:

  • Introduces MAX_PAGE_SIZE and updates multiple “fetch everything” call sites to use it instead of arbitrary large values.
  • Refines ensureSelfLink warning logic to only warn on meaningful differences after normalization, while keeping the self-link rewrite/caching behavior intact.
  • Adds a new Jasmine spec file covering ensureSelfLink behavior with 17 targeted cases.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/app/core/data/find-list-options.model.ts Adds MAX_PAGE_SIZE constant with documentation to avoid arbitrary oversized page-size requests.
src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.service.ts Uses MAX_PAGE_SIZE for bundle pagination requests (behavior-preserving vs server cap).
src/app/core/registry/registry.service.ts Replaces elementsPerPage: 10000 with MAX_PAGE_SIZE for schema retrieval.
src/app/core/data/relationship-type-data.service.ts Uses MAX_PAGE_SIZE for the single-page “load all relationship types” request.
src/app/core/data/bundle-data.service.ts Uses MAX_PAGE_SIZE as the default “load all bundles” fallback pagination size.
src/app/core/browse/browse.service.ts Uses MAX_PAGE_SIZE for browse definition retrieval.
src/app/admin/admin-reports/filtered-items/filtered-items.component.ts Uses MAX_PAGE_SIZE in several report-related findAll calls to avoid capped oversizing.
src/app/core/data/dspace-rest-response-parsing.service.ts Adds URL-part normalization helpers and filters console.warn to only unexpected self-link mismatches.
src/app/core/data/dspace-rest-response-parsing.service.spec.ts Adds comprehensive unit tests for ensureSelfLink mismatch/warning/normalization scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@milanmajchrak
milanmajchrak merged commit ca40c3b into customer/jcu Aug 7, 2026
6 checks passed
milanmajchrak added a commit that referenced this pull request Aug 11, 2026
The generic wording ends with "This could mean there's an issue with the REST
endpoint", which points at the backend. For a reduced page size that is the wrong
place to look: the API did nothing wrong, the caller asked for a bigger page than
it will serve.

  The request for '.../bundles?size=9999' asked for a page of 9999 elements, but
  the REST API served 1000. Ask for at most MAX_PAGE_SIZE elements

Anything else keeps the generic message, including a page that came back larger
than requested.

Also drops a stray note from the spec that was left in by #1440.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
milanmajchrak added a commit that referenced this pull request Aug 11, 2026
The generic wording ends with "This could mean there's an issue with the REST
endpoint", which points at the backend. For a reduced page size that is the wrong
place to look: the API did nothing wrong, the caller asked for a bigger page than
it will serve.

  The request for '.../bundles?size=9999' asked for a page of 9999 elements, but
  the REST API served 1000. Ask for at most MAX_PAGE_SIZE elements

Anything else keeps the generic message, including a page that came back larger
than requested.

Also drops a stray note from the spec that was left in by #1440.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
milanmajchrak added a commit that referenced this pull request Aug 11, 2026
…1448)

The generic wording ends with "This could mean there's an issue with the REST
endpoint", which points at the backend. For a reduced page size that is the wrong
place to look: the API did nothing wrong, the caller asked for a bigger page than
it will serve.

  The request for '.../bundles?size=9999' asked for a page of 9999 elements, but
  the REST API served 1000. Ask for at most MAX_PAGE_SIZE elements

Anything else keeps the generic message, including a page that came back larger
than requested.

Also drops a stray note from the spec that was left in by #1440.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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