Skip to content

Fix the causes of the self link mismatch console warnings - #6083

Open
milanmajchrak wants to merge 2 commits into
DSpace:mainfrom
dataquest-dev:fix-self-link-embed-mismatch
Open

Fix the causes of the self link mismatch console warnings#6083
milanmajchrak wants to merge 2 commits into
DSpace:mainfrom
dataquest-dev:fix-self-link-embed-mismatch

Conversation

@milanmajchrak

@milanmajchrak milanmajchrak commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

References

Description

ensureSelfLink() logs The response for '…' has the self link '…'. These don't match on healthy responses. Most of those are not mismatches at all; the remainder are caused by requests for page sizes the REST API cannot serve.

Instructions for Reviewers

The check compares the requested url against the self link in the response. Two of the differences it reported were not mismatches:

  • embed params are removed from the requested url before the comparison, but not from the self link, which echoes them back.
  • Encoding is compared literally. RequestParam encodes with encodeURIComponent while the REST API escapes only what it has to, so uri=http%3A%2F%2Fx returns as uri=http://x.

Both sides are now brought to the same form before being compared. The code that rewrites _links.self is unchanged, so caching is unaffected.

The third cause is on the frontend side. Spring Data REST caps a page at 1000, so a request for 9999 returns a self link saying 1000. MAX_PAGE_SIZE replaces the oversized values in the six call sites that used them: bundle-data, browse, relationship-type-data, registry, item-bitstreams and filtered-items. The API already capped each of these, so the same rows are returned. A reduced page size still warns, so an oversized request added later is still reported.

How to test: open an item page, the home page and /browse/title with the browser console open. Before the change each logs the warning, after it none do.

Checklist

  • My PR is created against the main branch of code.
  • My PR is small in size.
  • My PR follows all coding best practices based on the Code Conventions Guide.
  • My PR passes ESLint validation using npm run lint.
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps).
  • My PR includes TypeDoc comments for all new methods.
  • My PR passes all specs/tests and includes new/updated specs or tests.
  • My PR aligns with Accessibility guidelines: no UI changes.
  • My PR uses i18n keys: nothing user facing, the only string is a console warning.
  • My PR includes details on how to test it.
  • No new libraries or dependencies.

Written with some help from Claude Code.

ensureSelfLink compares the requested url against the self link in the response.
Two of the differences it reported were not mismatches:

- embed params are removed from the requested url before the comparison, but not
  from the self link, which echoes them back.
- encoding is compared literally. RequestParam encodes with encodeURIComponent
  while the REST API escapes only what it has to, so uri=http%3A%2F%2Fx returns as
  uri=http://x.

Both sides are now brought to the same form before being compared. Decoding is done
per url part after the split, so a decoded '&' cannot merge two params, and is
wrapped in try/catch because a malformed escape makes decodeURIComponent throw.

The code that rewrites _links.self is unchanged, so caching is unaffected.

The third cause is on the frontend side. Spring Data REST caps a page at
spring.data.rest.max-page-size, left at its default of 1000, so a request for 9999
returns a self link saying 1000. MAX_PAGE_SIZE replaces the oversized values in the
six call sites that used them:

  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

The API already capped each of these, so the same rows are returned. A reduced page
size still warns, so an oversized request added later is still reported.

browse-by-geospatial-data.component.ts is left unchanged: its 99999 is a Discovery
facet limit, not a page size.

Adds a spec for dspace-rest-response-parsing.service.ts, which had none.
@lgeggleston lgeggleston added bug error handling How errors are handled from REST API component: Item (Archived) Item display or editing labels Aug 10, 2026
@lgeggleston lgeggleston moved this to 🙋 Needs Reviewers Assigned in DSpace 11.0 Release Aug 10, 2026
@lgeggleston lgeggleston added port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release port to dspace-10_x This PR needs to be ported to `dspace-10_x` branch for next bug-fix release labels Aug 10, 2026
@lgeggleston

Copy link
Copy Markdown
Contributor

Thank you @milanmajchrak! It looks like it may make sense for this to fully link to/close out DSpace/DSpace#8577 - what do you think? Or, that question could also be left to reviewers.

Second, in the case of the remaining legitimate cause you mention of requests for page sizes the REST API cannot serve, would there be a way for the warning message to be more specific than the existing self link one in that case?

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.
@milanmajchrak

Copy link
Copy Markdown
Contributor Author

Thanks @lgeggleston!

  1. I think this PR closes the Bundles endpoint has incorrect "self link" (appears for item pages) DSpace#8577.
  2. Good idea, implemented: 887ddec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug component: Item (Archived) Item display or editing error handling How errors are handled from REST API port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release port to dspace-10_x This PR needs to be ported to `dspace-10_x` branch for next bug-fix release

Projects

Status: 🙋 Needs Reviewers Assigned

Development

Successfully merging this pull request may close these issues.

Bundles endpoint has incorrect "self link" (appears for item pages)

2 participants