Keep embed params out of subresource self links - #1388
Conversation
findRelInternal builds the self link from the raw query string, so /items/<uuid>/bundles?embed=primaryBitstream reports a self link that is not the resource that was requested: GET /api/core/items/<uuid>/bundles?embed=primaryBitstream&size=10 self .../bundles?embed=primaryBitstream&size=10 The collection and search endpoints already exclude embed params, through getEncodedParameterStringFromRequestParams - added by PR DSpace#3105 to fix DSpace#3062, but never wired into the subresource path. That is why DSpace#8577 is still open. Filter embed and embed.* out of the query string before building the link. Every other parameter is passed through verbatim rather than rebuilt, so a client's own percent-encoding survives untouched. Related to DSpace#8577
Nedávať zatiaľ merge — našiel som regresiu
private Href _link(final Sort sort, Integer page, int size) {
UriComponentsBuilder uriComp = self.cloneBuilder();Takže keď z self linku vypadne Väčšine frontendu to nevadí — napr. // browse-by-metadata-page.component.ts
goNext() { ... this.browseService.getNextBrowseItems(items); }
// browse.service.ts
return this.hrefOnlyDataService.findListByHref<Item>(items.payload.next);A Poznámka: kolekcie a search týmto trpia už dnes — ide o rovnaký builder — takže táto zmena len rozširuje existujúce upstream správanie. To ale z regresie nerobí nie-regresiu. Odporúčanie: nemergovať. Warning už rieši FE strana (dataquest-dev/dspace-angular#1415) bez tohto rizika. Ak by sme chceli self link opraviť poriadne, treba oddeliť builder pre |
|
Closing: the frontend fix (dataquest-dev/dspace-angular#1415) removes the warning without this regression risk. See the previous comment on EmbeddedPageHeader pagination links. |
References
good first issue, never fixedDescription
Subresource list endpoints put the request's
embedparameters into their ownselflink, so/items/<uuid>/bundles?embed=primaryBitstreamreports a self link that isn't the resource that wasrequested. Collection and search endpoints already exclude them; this does the same for subresources.
Instructions for Reviewers
RestResourceController.findRelInternalbuilds the self link from the raw query string:The collection (
findAllInternal) and search (executeSearchMethods) paths instead go throughgetEncodedParameterStringFromRequestParams, which dropsembedandembed.*. That helper wasadded by PR 3105 to fix issue 3062 — but it was never wired into the subresource path, which is why
issue 8577 is still open.
List of changes in this PR:
removeEmbedParamsFromQueryString, and used it infindRelInternal. It filters out onlyembedandembed.*and passes every other parameter through verbatim — no re-encoding, so aclient's own percent-encoding is preserved.
BundleRestRepositoryIT.getItemBundlesSelfLinkHasNoEmbedParams, asserting the self linkkeeps
size=10and no longer containsembed.How to test:
Before:
"self": ".../bundles?embed=primaryBitstream&size=10"After:
"self": ".../bundles?size=10"A real DSpace 9.1 instance returns this for an item page load, which is what the frontend reports as
"The response for … has the self link … These don't match":
Worth a reviewer's attention: when every parameter was an
embedone, the self link now has no querystring at all — that is the intended result, and it is what the collection endpoints already do.
Checklist
mainbranch of code — no: fork PR, base isdtq-dev. Thesame change applies to upstream
main; a patch is prepared separately for a human to submit.mvn -pl dspace-server-webapp checkstyle:check, exit 0).written, but it has not been executed: DSpace's test harness needs a configured
dspace.dir,which this machine doesn't have (
dspace-apitests fail the same way on an untouched checkout).The filter logic itself was verified in
jshellagainst the real query strings, including thatembedded=xis not stripped. Someone with a working test environment should run the IT.existing
selflink, which the REST Contract already describes as not carrying parameters thatcan't affect the resource.