Skip to content

Say what actually happened when the REST API reduces a page size - #1448

Merged
milanmajchrak merged 1 commit into
customer/jcufrom
fix/862-specific-page-size-warning-jcu
Aug 11, 2026
Merged

Say what actually happened when the REST API reduces a page size#1448
milanmajchrak merged 1 commit into
customer/jcufrom
fix/862-specific-page-size-warning-jcu

Conversation

@milanmajchrak

@milanmajchrak milanmajchrak commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

References

Description

After #1440 one self link warning is still reported on purpose: a caller asking for a page size the REST API won't serve. The generic message blames the endpoint, which is wrong for that case, so it gets its own.

Instructions for Reviewers

Before:

The response for '.../bundles?size=9999' has the self link '.../bundles?size=1000'.
These don't match. This could mean there's an issue with the REST endpoint

After:

The request for '.../bundles?size=9999' asked for a page of 9999 elements, but the REST API
served 1000. It won't put more than MAX_PAGE_SIZE elements in a page, so this request can't
get what it asks for

Only when the page size is the only difference and the served one is smaller. Everything else keeps the generic message.

How to test: set an elementsPerPage above 1000 somewhere, load the page, read the console.

Checklist

  • My PR is small in size.
  • My PR passes ESLint validation.
  • My PR doesn't introduce circular dependencies.
  • My PR includes TypeDoc comments for all new methods.
  • My PR passes all specs/tests and includes new/updated specs or tests.
  • My PR includes details on how to test it.
  • Base is customer/jcu, not main.

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 refines the console warning emitted by ensureSelfLink so that when the only mismatch is the REST API capping a requested size parameter to a smaller value, the warning explains that the caller requested an unservable page size rather than implying an endpoint problem.

Changes:

  • Add URL parsing helpers to detect when the self link differs solely due to a reduced size parameter.
  • Introduce a dedicated warning message for “requested page size reduced by REST API” cases; otherwise keep the existing generic warning.
  • Extend unit tests to cover the new reduced-page-size warning behavior and fallback scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/app/core/data/dspace-rest-response-parsing.service.ts Adds page-size extraction and conditional warning generation for reduced page-size self link mismatches.
src/app/core/data/dspace-rest-response-parsing.service.spec.ts Updates specs to assert the new reduced-page-size warning and verify fallback to the generic warning.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/app/core/data/dspace-rest-response-parsing.service.ts Outdated
Comment thread src/app/core/data/dspace-rest-response-parsing.service.spec.ts
Comment thread src/app/core/data/dspace-rest-response-parsing.service.ts Outdated

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

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

@milanmajchrak
milanmajchrak force-pushed the fix/862-specific-page-size-warning-jcu branch from 3f0664d to 83f840d Compare August 11, 2026 07:09
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
milanmajchrak force-pushed the fix/862-specific-page-size-warning-jcu branch from 83f840d to bdd533a Compare August 11, 2026 07:20
@milanmajchrak
milanmajchrak requested a balanced review from Copilot August 11, 2026 10:27

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

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

@milanmajchrak
milanmajchrak merged commit 382a721 into customer/jcu Aug 11, 2026
6 checks passed
milanmajchrak added a commit that referenced this pull request Aug 27, 2026
…ces a page size (#1490)

ensureSelfLink() logs one wording for every self link that differs from the url
it was requested with, and that wording ends with "This could mean there's an
issue with the REST endpoint". For a page size the API reduced, that points at
the wrong place: the API did exactly what its contract says, the caller asked
for a bigger page than it will ever serve. Whoever reads the console goes
looking at the backend for a frontend mistake.

Give that case its own message:

  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

It applies only when the two urls are otherwise identical, so an accepted
reduction cannot mask a wrong page or sort. Anything else keeps the generic
message, including a page that came back larger than requested.

This is the remaining half of the fix on dtq-dev. #1415 landed the rest - embed
params and percent encoding normalized on both sides, MAX_PAGE_SIZE next to
FindListOptions, and every oversized call site brought within it - so a reduced
page size now genuinely means a caller asked for something the API was never
going to serve, and the message can say so.

- src/app/core/data/dspace-rest-response-parsing.service.ts - replace
  isUnexpectedSelfLink() with selfLinkWarning(), which returns the message to
  log or undefined when there is nothing to report, and add the
  getPageSize()/withoutPageSize() helpers and the PAGE_SIZE_PARAM they match on.
  The self link is normalized either way, as before, so the url a response is
  cached under does not change - only whether and how we warn.
- src/app/core/data/dspace-rest-response-parsing.service.spec.ts - 17 cases to
  19. The reduced page size case now expects the specific wording; one new case
  pins that a reduced size is recognised alongside other params, another that a
  page differing as well falls back to the generic message.

Adapted to 7.6 from DSpace/dspace-angular PR 6083, commit 887ddec. The
9.x-only parts of that commit's file - the @dspace/* path aliases and the
inject(APP_CONFIG) refactor - are deliberately left out, which is also why the
spec keeps its plain constructor harness instead of upstream's TestBed. Same
change as #1448, which went to customer/jcu only.

Fixes dataquest-dev/dspace-customers#934

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