Skip to content

Featured Items API can now retrieve images for creator - #12381

Open
stevenwinship wants to merge 1 commit into
developfrom
11537-featured-items-retrieve-image-bug
Open

Featured Items API can now retrieve images for creator#12381
stevenwinship wants to merge 1 commit into
developfrom
11537-featured-items-retrieve-image-bug

Conversation

@stevenwinship

Copy link
Copy Markdown
Contributor

What this PR does / why we need it: Creator of a featured item of a non published dataverse could not see the images.

Which issue(s) this PR closes:#11537

Special notes for your reviewer:

Suggestions on how to test this: See DataversesIT testListFeaturedItems.

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

Is there a release notes update needed for this change?: included

Additional documentation:

@stevenwinship stevenwinship self-assigned this May 5, 2026
@github-actions github-actions Bot added FY26 Sprint 22 FY26 Sprint 22 (2026-04-22 - 2026-05-06) Original size: 3 SPA These changes are required for the Dataverse SPA SPA.Q2 Not related to any specific Q2 feature Type: Bug a defect labels May 5, 2026
@stevenwinship stevenwinship moved this to In Progress 💻 in IQSS Dataverse Project May 5, 2026
@coveralls

coveralls commented May 5, 2026

Copy link
Copy Markdown

Coverage Status

Coverage is 24.974%11537-featured-items-retrieve-image-bug into develop. No base build found for develop.

@github-actions

This comment has been minimized.

@stevenwinship stevenwinship moved this from In Progress 💻 to Ready for Review ⏩ in IQSS Dataverse Project May 5, 2026
@stevenwinship stevenwinship removed their assignment May 5, 2026
@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from 6f1095d to 17d5660 Compare May 6, 2026 18:11
@github-actions

This comment has been minimized.

@cmbz cmbz added the FY26 Sprint 23 FY26 Sprint 23 (2026-05-06 - 2026-05-20) label May 6, 2026
@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from 17d5660 to c7865f3 Compare May 7, 2026 19:51
@github-actions

This comment has been minimized.

@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from c7865f3 to 45f1a22 Compare May 11, 2026 13:18
@github-actions

This comment has been minimized.

@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from 45f1a22 to 5a224a9 Compare May 12, 2026 15:38
@github-actions

This comment has been minimized.

@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from 5a224a9 to 7269a84 Compare May 13, 2026 13:13
@github-actions

This comment has been minimized.

@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from 7269a84 to 49ee2af Compare May 13, 2026 19:25
@github-actions

This comment has been minimized.

@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from 49ee2af to 5dafcc2 Compare May 20, 2026 18:00
@github-actions

This comment has been minimized.

@cmbz cmbz added the FY26 Sprint 24 FY26 Sprint 24 (2026-05-20 - 2026-06-03) label May 21, 2026
@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from 5dafcc2 to 925c3a8 Compare May 21, 2026 20:17
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@cmbz cmbz added the FY26 Sprint 26 FY26 Sprint 26 (2026-06-17 - 2026-07-01) label Jun 18, 2026
@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from cebec54 to 52f8f11 Compare June 22, 2026 17:42
@github-actions

This comment has been minimized.

@cmbz cmbz added the FY27 Sprint 1 FY27 Sprint 1 (2026-07-01 - 2026-07-15) label Jul 1, 2026
@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from 52f8f11 to 2e15bcd Compare July 2, 2026 13:14
@github-actions

This comment has been minimized.

@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from 2e15bcd to 49b5bbd Compare July 2, 2026 20:44
@github-actions

This comment has been minimized.

@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from 49b5bbd to a290572 Compare July 13, 2026 14:24
@github-actions

This comment has been minimized.

@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from a290572 to 727260f Compare July 13, 2026 18:10
@github-actions

This comment has been minimized.

@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from 727260f to fdd9788 Compare July 13, 2026 19:55
@github-actions

This comment has been minimized.

@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from fdd9788 to a620402 Compare July 13, 2026 20:36
@github-actions

This comment has been minimized.

@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from a620402 to fb805ec Compare July 15, 2026 13:05
@github-actions

This comment has been minimized.

@cmbz cmbz added the FY27 Sprint 2 FY27 Sprint 2 (2026-07-15 - 2026-07-29) label Jul 15, 2026
@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from fb805ec to d988c97 Compare July 20, 2026 13:04
@github-actions

This comment has been minimized.

@stevenwinship
stevenwinship force-pushed the 11537-featured-items-retrieve-image-bug branch from d988c97 to d45be96 Compare July 22, 2026 15:35
@github-actions

Copy link
Copy Markdown

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:11537-featured-items-retrieve-image-bug
ghcr.io/gdcc/configbaker:11537-featured-items-retrieve-image-bug

🚢 See on GHCR. Use by referencing with full name as printed above, mind the registry name.

@rtreacy rtreacy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude
PR #12381 Review: Featured Items API can now retrieve images for creator

What it does

Fixes #11537: the creator of an unpublished dataverse couldn't view/download their own featured-item images, because GetDataverseFeaturedItemCommand.getRequiredPermissions() unconditionally required Permission.ViewUnpublishedDataverse whenever the dataverse wasn't released — with no allowance for the dataverse's own creator. The fix adds an explicit carve-out: if the requesting user equals dataverseFeaturedItem.getDataverse().getCreator(), no permission is required, same as the published case.

Correctness

  • getRequest().getUser().equals(...) is safe against the two null-ish edge cases that matter: an anonymous/guest user (GuestUser.equals falls back to reference equality against an AuthenticatedUser → false, correctly not treated as creator) and a dataverse with no recorded creator (getCreator() returns null; AuthenticatedUser.equals(null) returns false via the instanceof guard, so the code correctly falls back to requiring ViewUnpublishedDataverse rather than NPEing or accidentally granting access).
  • AuthenticatedUser.equals() compares by database ID (DvObject.java/AuthenticatedUser.java:439), not reference identity, so comparing the request's live user object against the JPA-loaded creator relationship works correctly across different object instances.
  • The fix is narrowly scoped — it changes behavior only for the literal creator of the dataverse; every other user (including dataverse admins/curators without the creator flag) still goes through the unchanged ViewUnpublishedDataverse check, so there's no broadened attack surface beyond the intended case.
  • @AuthRequired on the Access.getDataverseFeatureItemImage endpoint guarantees an authenticated user reaches this command, so there's no unauthenticated-guest path to worry about here.

Test coverage

  • The new assertions in testListFeaturedItems exercise the actual bug: the dataverse in that test is never published (unlike the sibling testUpdateFeaturedItems, which explicitly publishes), so isReleased() is false and the fixed branch is genuinely exercised — this isn't a test that would've passed before the fix, which is exactly what you want for a regression test.
  • Confirms both sides: creator's token → 200, unrelated random user's token → 204 (matching this endpoint's existing convention of returning null/204 rather than 403 on permission failure — pre-existing behavior in Access.java, unaffected by this PR).
  • No test for a non-creator user who does have ViewUnpublishedDataverse (e.g., a curator role-assignee) still succeeding — that path is unchanged by this diff and was presumably already covered elsewhere, so it's a minor gap rather than a real risk.

Style (minor, non-blocking)

  • Collections.singletonMap("",Collections.emptySet()) is missing a space after the comma — trivial whitespace nit.
  • The double-negative condition (!isReleased() && !user.equals(creator)) reads a little awkwardly; something like a single boolean (isCreator) combined with isReleased() || isCreator in a ternary would be marginally more readable, but this is a matter of taste, not a defect.

Verdict

Small, well-targeted bug fix with a test that actually proves the fix works and would have failed before it. No correctness, security, or regression concerns. Good to merge as-is; the style nits aren't worth blocking on.

@github-project-automation github-project-automation Bot moved this from Ready for Review ⏩ to Ready for QA ⏩ in IQSS Dataverse Project Jul 23, 2026
@rtreacy rtreacy assigned rtreacy and unassigned rtreacy Jul 23, 2026
@cmbz cmbz added the FY27 Sprint 3 FY27 Sprint 3 (2026-07-29 - 2026-08-12) label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FY26 Sprint 22 FY26 Sprint 22 (2026-04-22 - 2026-05-06) FY26 Sprint 23 FY26 Sprint 23 (2026-05-06 - 2026-05-20) FY26 Sprint 24 FY26 Sprint 24 (2026-05-20 - 2026-06-03) FY26 Sprint 25 FY26 Sprint 25 (2026-06-03 - 2026-06-17) FY26 Sprint 26 FY26 Sprint 26 (2026-06-17 - 2026-07-01) FY27 Sprint 1 FY27 Sprint 1 (2026-07-01 - 2026-07-15) FY27 Sprint 2 FY27 Sprint 2 (2026-07-15 - 2026-07-29) FY27 Sprint 3 FY27 Sprint 3 (2026-07-29 - 2026-08-12) Original size: 3 SPA.Q2 Not related to any specific Q2 feature SPA These changes are required for the Dataverse SPA Type: Bug a defect

Projects

Status: Ready for QA ⏩

Development

Successfully merging this pull request may close these issues.

Feature Items API Unable to Retrieve Images from Unpublished Collections

4 participants