Skip to content

Dataset Page: Guest User can't get file info for a deaccessioned dataset #776

Merged
ofahimIQSS merged 9 commits intodevelopfrom
Refactor-api-calls-for-deaccessioned-dataset
Aug 26, 2025
Merged

Dataset Page: Guest User can't get file info for a deaccessioned dataset #776
ofahimIQSS merged 9 commits intodevelopfrom
Refactor-api-calls-for-deaccessioned-dataset

Conversation

@ChengShi-1
Copy link
Copy Markdown
Contributor

@ChengShi-1 ChengShi-1 commented Jul 18, 2025

What this PR does / why we need it:

download/count and downloadsize will return 404 for user: guests, the getByPersistentId should be refactored to adapt the change

If user:guest and the dataset is deaccessioned:

dataset is ok to show basic info, versions and deaccessioned reason
NO File info could be shown, cannot direct to file page as well
Hide share button
Hide metric(prevent fetching download/count

Which issue(s) this PR closes:

Special notes for your reviewer:

⚠️ waiting for IQSS/dataverse#11702

Suggestions on how to test this:

As a guest user, in a dataset, check if the dataset metric component and the Share button is hidden. As a dataset owner, check if the dataset metric component and the Share button is shown.

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

image

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

Additional documentation:

@github-actions github-actions Bot added bug Something isn't working FY26 Sprint 2 FY26 Sprint 2 (2025-07-16 - 2025-07-30) SPA.Q3.2025 SPA: Dataset page (View) labels Jul 18, 2025
@ChengShi-1 ChengShi-1 added Size: 3 A percentage of a sprint. 2.1 hours. Original size: 3 labels Jul 18, 2025
@coveralls
Copy link
Copy Markdown

coveralls commented Jul 18, 2025

Coverage Status

coverage: 97.473% (-0.6%) from 98.052%
when pulling 8a3ef41 on Refactor-api-calls-for-deaccessioned-dataset
into fc16e44 on develop.

@ChengShi-1 ChengShi-1 moved this to Ready for Review ⏩ in IQSS Dataverse Project Jul 18, 2025
@ChengShi-1 ChengShi-1 marked this pull request as ready for review July 18, 2025 18:56
@cmbz cmbz added the FY26 Sprint 3 (2025-07-30 - 2025-08-13) label Jul 31, 2025
@ChengShi-1 ChengShi-1 moved this from Ready for Review ⏩ to In Progress 💻 in IQSS Dataverse Project Aug 11, 2025
@ChengShi-1 ChengShi-1 self-assigned this Aug 11, 2025
@ChengShi-1 ChengShi-1 removed their assignment Aug 12, 2025
@ChengShi-1 ChengShi-1 moved this from In Progress 💻 to Ready for Review ⏩ in IQSS Dataverse Project Aug 12, 2025
@cmbz cmbz added the FY26 Sprint 4 FY26 Sprint 4 (2025-08-13 - 2025-08-27) label Aug 14, 2025
@ChengShi-1 ChengShi-1 added the SPA label Aug 21, 2025
@g-saracca g-saracca added the GREI Re-arch GREI re-architecture-related label Aug 21, 2025
@g-saracca g-saracca self-assigned this Aug 21, 2025
@g-saracca g-saracca moved this from Ready for Review ⏩ to In Review 🔎 in IQSS Dataverse Project Aug 21, 2025
Copy link
Copy Markdown
Contributor

@g-saracca g-saracca left a comment

Choose a reason for hiding this comment

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

Hi @ChengShi-1 , some comments here 👍🏼

/>

<ShareDatasetButton />
{(!isCurrentVersionDeaccessioned || canUpdateDataset) && <ShareDatasetButton />}
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.

Is this logic replicating JSF condition?

Comment thread src/sections/dataset/Dataset.tsx
new FileDownloadSize(0, FileSizeUnit.BYTES, FileDownloadMode.ORIGINAL),
new FileDownloadSize(0, FileSizeUnit.BYTES, FileDownloadMode.ARCHIVAL)
])
})
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.

Why are we deleting the test 'gets the dataset by persistentId when is locked'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wrongly overwrite this test while merging conflict :( I'll recover this

// If the server returns NOT_FOUND when deaccessioned info isn't included, ignore and continue without sizes.
return datasetDetails
}
throw error
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.

I dont understand this, why this checking for 404? Is the description of this PR outdated?
In steves PR I see this comment "guest user should see deaccessioned file count and download size"

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.

Also you could use JSDataverseReadErrorHandler and don't cast the error error: ReadError, as you could have other many types of errors. Try something like this:

} catch (err: ReadError | unknown) {
        if (err instanceof ReadError) {
          const error = new JSDataverseReadErrorHandler(err)
          const statusCode = error.getStatusCode()
          if (statusCode === 404) return datasetDetails
        } else if (err instanceof Error && err.message.includes('404')) {
          return datasetDetails
        } else {
          throw error
        }
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@g-saracca Sorry, the description said it should return 403, but it actually it returns 404.

  • For guest users with includeDeaccessioned=false: Returns 404 Not Found
  • For guest users with includeDeaccessioned=true: Returns 200 OK with download size.

Also, alternatively, if the dataset is deaccessioned and canEditDataset is false, skip calling the downloadSize endpoints and keep the defaults, avoiding the error path entirely. Do you think it will be better?

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.

Sorry I still don't understand.
If you are a guest user and do NOT request to include deaccessioned version you will receive a 404, but you will receive a 200 ok being a guest user requesting a deaccessioned version? how can be that way?
I'm lost with this thing sorry 🙏🏼

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, guest user could still access files' downloadSize info for deaccessioned dataset, which will work for a deaccessioned tombstone

Important Note: A tombstone landing page with the basic citation metadata will always be accessible to the public if they use the persistent URL (Handle or DOI) provided in the citation for that dataset. Users will not be able to see any of the files or additional metadata that were previously available prior to deaccession.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For the backend, the issue was includeDeaccessioned=true, user: guest returns 404, so they fixed, now it returns 200.

In the UI, if we don't skip the 404, the UI will be 404 error page.
The downloadSize is a part of getByPersistentId in datasetJSDataverseRepository, and fileDownloadSizes is a field of the Dataset model. In order to prevent the showing of 404 error page, I catches 404 here.

You should not be sorry, this is truly confusing, I am not sure if I did it right. Thanks for helping!

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.

Ok I think I understand now, try to use the suggestion I made for catching the error in a more robust way.

@github-project-automation github-project-automation Bot moved this from In Review 🔎 to Ready for QA ⏩ in IQSS Dataverse Project Aug 26, 2025
@ofahimIQSS ofahimIQSS self-assigned this Aug 26, 2025
@ofahimIQSS ofahimIQSS moved this from Ready for QA ⏩ to QA ✅ in IQSS Dataverse Project Aug 26, 2025
@ofahimIQSS
Copy link
Copy Markdown
Contributor

image

Looks good to me, merging.

@ofahimIQSS ofahimIQSS merged commit 9c0288e into develop Aug 26, 2025
10 of 14 checks passed
@github-project-automation github-project-automation Bot moved this from QA ✅ to Merged 🚀 in IQSS Dataverse Project Aug 26, 2025
@ofahimIQSS ofahimIQSS deleted the Refactor-api-calls-for-deaccessioned-dataset branch August 26, 2025 15:49
@ofahimIQSS ofahimIQSS removed their assignment Aug 26, 2025
@scolapasta scolapasta moved this from Merged 🚀 to Done 🧹 in IQSS Dataverse Project Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working FY26 Sprint 2 FY26 Sprint 2 (2025-07-16 - 2025-07-30) FY26 Sprint 3 (2025-07-30 - 2025-08-13) FY26 Sprint 4 FY26 Sprint 4 (2025-08-13 - 2025-08-27) GREI Re-arch GREI re-architecture-related Original size: 3 Size: 3 A percentage of a sprint. 2.1 hours. SPA: Dataset page (View) SPA.Q3.2025 SPA

Projects

Status: Done 🧹

Development

Successfully merging this pull request may close these issues.

Prevent guests of a deaccessioned dataset from getting file's info

6 participants