Skip to content

Fixing external tools with guestbook responses - #12801

Open
stevenwinship wants to merge 11 commits into
developfrom
12760-previewers-not-working-with-guestbook-responses
Open

stevenwinship wants to merge 11 commits into
developfrom
12760-previewers-not-working-with-guestbook-responses

Conversation

@stevenwinship

@stevenwinship stevenwinship commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it: External tools can't download files that require/have a guestbook response

Which issue(s) this PR closes:#12760

Special notes for your reviewer:

Suggestions on how to test this: Create a dataset with multiple files to preview. Add a guestbook to the dataset and publish. Test previewing the files and download from the external tool. Test files with restricted access.
Download timeout comes from the external tool params. Try creating an external tool with a 1 minute timeout and make sure the signed url expires.

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 Oct 6, 2026
@stevenwinship stevenwinship added Size: 30 A percentage of a sprint. 21 hours. (formerly size:33) Type: Bug a defect labels Oct 6, 2026
@stevenwinship stevenwinship added this to the 6.13 milestone Oct 6, 2026
@coveralls

coveralls commented Oct 6, 2026 •

Copy link
Copy Markdown

Coverage Status

Coverage is 25.666% — 12760-previewers-not-working-with-guestbook-responses into develop. No base build found for develop.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Test Results

417 tests  ±0   403 ✅ ±0   24m 6s ⏱️ - 7m 48s
 59 suites ±0    14 💤 ±0 
 59 files   ±0     0 ❌ ±0 

Results for commit e148396. ± Comparison against base commit 3cbdeab.

♻️ This comment has been updated with latest results.

@github-actions

This comment has been minimized.

@stevenwinship stevenwinship removed their assignment Oct 6, 2026
@stevenwinship stevenwinship added the FY27 Sprint 7 FY27 Sprint 7 (2026-09-23 - 2026-10-07) label Oct 6, 2026
@landreev landreev self-assigned this Oct 7, 2026
@cmbz cmbz added the FY27 Sprint 8 FY27 Sprint 8 (2026-10-07 - 2026-10-21) label Oct 7, 2026
@landreev

Copy link
Copy Markdown
Contributor

Could you please sync the branch up with develop.

@landreev

landreev commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

@stevenwinship
It may be something I'm doing, but it's still not working for me.
I have an audio file with a guestbook and the audio previewer installed locally. Looking at the javascript console, the callback url doesn't appear to have the new guestbookresponse id parameter:

http://localhost:8080/previewers/v1.5/AudioPreview.html?callback=aHR0cDovLzEyNy4wLjAuMTo4MDgwL2FwaS92MS9maWxlcy8xNi9tZXRhZGF0YS8yL3Rvb2xwYXJhbXMvNA==&locale=en&preview=true

decoded:

echo "aHR0cDovLzEyNy4wLjAuMTo4MDgwL2FwaS92MS9maWxlcy8xNi9tZXRhZGF0YS8yL3Rvb2xwYXJhbXMvNA==" | base64 -d 
http://127.0.0.1:8080/api/v1/files/16/metadata/2/toolparams/4

This in turn produces an /access url without the gbrid, which bombs with a 400.

Please advise.

@stevenwinship
stevenwinship force-pushed the 12760-previewers-not-working-with-guestbook-responses branch from 86741c7 to fea5d34 Compare October 14, 2026 13:05
@github-actions

This comment has been minimized.

@stevenwinship

stevenwinship commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Did you install your own external tool? If so did you include "gbrecs=false" or "gbrecs=true" in the allowedapicalls?
I don't see it in your urls above.

This is what it looks for to add the gb response id. I'll look into changing it so it gets added either way

[{"name":"retrieveFileContents","httpMethod":"GET","urlTemplate":"/api/v1/access/datafile/{fileId}?gbrecs=true","timeOut":3600},{"name":"downloadFile","httpMethod":"GET","urlTemplate":"/api/v1/access/datafile/{fileId}?gbrecs=false","timeOut":3600},{"name":"getDatasetVersionMetadata","httpMethod":"GET","urlTemplate":"/api/v1/datasets/{datasetId}/versions/{datasetVersion}","timeOut":3600}]

@landreev

Copy link
Copy Markdown
Contributor

I installed the tool using the standard command as published. Which in my case was:

curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \
'{                                            
  "displayName":"Play Audio",    
  "description":"Listen to an audio file.",
  "toolName":"audioPreviewer",
  "scope":"file",                    
  "types":["preview"],    
  "toolUrl":"http://localhost:8080/previewers/v1.5/AudioPreview.html",
  "toolParameters": {                
      "queryParameters":[ 
        {"fileid":"{fileId}"},                                      
        {"siteUrl":"{siteUrl}"},
        {"datasetid":"{datasetId}"},
        {"datasetversion":"{datasetVersion}"},                       
        {"locale":"{localeCode}"}
      ]                   
    },                                                               
  "contentType":"audio/mpeg",             
  "allowedApiCalls": [    
    {                                                                         
      "name": "retrieveFileContents",     
      "httpMethod": "GET",
      "urlTemplate": "/api/v1/access/datafile/{fileId}?gbrecs=true",          
      "timeOut": 3600 
    },                    
    {                                                               
      "name": "downloadFile",   
      "httpMethod": "GET",          
      "urlTemplate": "/api/v1/access/datafile/{fileId}?gbrecs=false",
      "timeOut": 3600            
    },                    
    {                                                                
      "name": "getDatasetVersionMetadata",
      "httpMethod": "GET",
      "urlTemplate": "/api/v1/datasets/{datasetId}/versions/{datasetVersion}",
      "timeOut": 3600                     
    }                     
  ]                                                                           
}'

seems to be the same - i.e., gbrecs=true for the retrieveFileContents (the main access url that the player uses), and gbrecs=false for the download one, just like in your command below. (but please double-check)
If the installation commands need to be changed/tools need to be reinstalled, that will need to be documented in the release note.

Did you install your own external tool? If so did you include "gbrecs=false" or "gbrecs=true" in the allowedapicalls? This is what it looks for to add the gb id. I'll look into changed it so it gets added either way

[{"name":"retrieveFileContents","httpMethod":"GET","urlTemplate":"/api/v1/access/datafile/{fileId}?gbrecs=true","timeOut":3600},{"name":"downloadFile","httpMethod":"GET","urlTemplate":"/api/v1/access/datafile/{fileId}?gbrecs=false","timeOut":3600},{"name":"getDatasetVersionMetadata","httpMethod":"GET","urlTemplate":"/api/v1/datasets/{datasetId}/versions/{datasetVersion}","timeOut":3600}]

@landreev

Copy link
Copy Markdown
Contributor

Do I need to re-test, with your latest commits from 1 hour ago? Or are these the same initial commits from force-pushing the branch?

I'm getting errors/warning from git pull origin 12760-previewers-not-working-with-guestbook-responses as well:

hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
...

@landreev

Copy link
Copy Markdown
Contributor

... otherwise I can report another issue that I may be seeing.

@stevenwinship

Copy link
Copy Markdown
Contributor Author

My latest commit was just a merge from develop

@landreev

Copy link
Copy Markdown
Contributor

I figured; but they are showing as new commits this am, above. I'm assuming because of a force-push?

Since we do want/need to have the gbrids= in the main access url, it should probably have gbrecs=false, not true - (false means "do not write a new gbr", right?)

@qqmyers

qqmyers commented Oct 14, 2026

Copy link
Copy Markdown
Member

FWIW: ignoring when a gb is assigned, gbrecs determines whether an entry is made that signifies a download, so the main preview needs/needed true to avoid the API writing a download count. At some point, we decided that a preview is close enough to a download that we want to ask the guestbook questions, but I don't think we ever decided that, in the no guestbook case, previews should count as downloads.

@landreev

landreev commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

In other words, I was wrong above - in that gbrecs=true actually means "do NOT write a new gbr"?

On a side note, I'm not seeing either gbrecs or gbrids mentioned anywhere in the guides. (am I missing something?)

FWIW: ignoring when a gb is assigned, gbrecs determines whether an entry is made that signifies a download, so the main preview needs/needed true to avoid the API writing a download count. At some point, we decided that a preview is close enough to a download that we want to ask the guestbook questions, but I don't think we ever decided that, in the no guestbook case, previews should count as downloads.

@landreev

Copy link
Copy Markdown
Contributor

In other words, I was wrong above - in that gbrecs=true actually means "do NOT write a new gbr"?

Of course; I misread the code in Access.java earlier.

@stevenwinship

stevenwinship commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

I've been trying to reproduce your (@landreev) error using both .wav and .mpeg files. I am getting the dialog to enter the gb info and then I get the download to happen correctly with the id

{"name":"downloadFile","httpMethod":"GET","urlTemplate":"/api/v1/access/datafile/{fileId}?gbrecs=true&gbrids=4","timeOut":3600},

Note: I can preview the wav file but I don't see the "eye" with the mpeg

@stevenwinship stevenwinship removed their assignment Oct 21, 2026
@github-actions

This comment has been minimized.

@stevenwinship

stevenwinship commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

With this latest commit the url given to the external tool for download purposes will expire in 60 minutes. The signed url still retains the timeout from the tools configuration but it will not be honored beyond the 60 minutes.
ie. the signed part has a timeout equal to the configuration but the Access API endpoint will block if over 60 minutes. If the api gets called by a download (not external tool) the timeout remains at 1 minute since this is a two pass POST/GET from the ui and doesn't take much time to complete.

The external tool download will still create "Explore" and "View Image" guestbook responses (when clicking preview(EYE) and "Open in new window") but will not generate the "Download" response.

EDIT: I don't think the "View Image" matters. Seems it's just the name of the previewer. So it doesn't seem to have a negative effect on the download count.
/** Event Types - there are four pre-defined values in use.
* The type can also be the name of a previewer/explore tool
*/

@landreev

landreev commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Sorry for the delay. Re-testing and looking at the code now; especially interested r/n in what I can get away with as a guest user.
Will try to wrap it up soon.

@landreev

Copy link
Copy Markdown
Contributor

The previewers are now working on files w/ explicit guestbooks, for an hour, as planned.
My only request is let's make both GUESTBOOK_RESPONSE_SIGNEDURL_TIMEOUT_MINUTES and GUESTBOOK_RESPONSE_EXTERNAL_TOOL_TIMEOUT_MINUTES configurable, via dataverse.api.* jvm options, with the current values as the defaults.
If an instance has a reason to want either of these to be a week, or 5 minutes, they should have a way to have that.

I also have an observation that I want to document, will do separately.


// Process the guestbook response from JSON and return a signedUrl to the matching GET call
private Response processDatafilesWithGuestbookResponse(ContainerRequestContext crc, DataverseRequest req, HttpHeaders headers, List<String> fileIdsList, UriInfo uriInfo, boolean gbrecs, String jsonBody) {
private Response processDatafilesWithGuestbookResponse(ContainerRequestContext crc, DataverseRequest req, HttpHeaders headers, List<String> fileIdsList, UriInfo uriInfo, boolean gbrecs, Long externalToolId, String jsonBody) {

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.

What is the bot complaining about here, the "Cognitive Complexity" business - does it have any merit?

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 removed 1 of the unused method params. I don't know who decided that 15 was a limit. I'm not removing what's needed or creating a class to pass multiple values.

Comment thread src/main/java/edu/harvard/iq/dataverse/api/Access.java Outdated
@stevenwinship
stevenwinship force-pushed the 12760-previewers-not-working-with-guestbook-responses branch from 08c82e7 to 556a1be Compare October 29, 2026 14:54
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@landreev

Copy link
Copy Markdown
Contributor

I'd like to make an effort and merge this PR asap.
But what about this one remaining request? - I would like to have these configurable.

The previewers are now working on files w/ explicit guestbooks, for an hour, as planned. My only request is let's make both GUESTBOOK_RESPONSE_SIGNEDURL_TIMEOUT_MINUTES and GUESTBOOK_RESPONSE_EXTERNAL_TOOL_TIMEOUT_MINUTES configurable, via dataverse.api.* jvm options, with the current values as the defaults. If an instance has a reason to want either of these to be a week, or 5 minutes, they should have a way to have that.

I also have an observation that I want to document, will do separately.

@landreev

Copy link
Copy Markdown
Contributor

(Sorry if you are still working on it - I didn't see your name assigned and assumed it was ready for retesting)

export TOOL_ID=3

curl -H "X-Dataverse-key:$API_TOKEN" -X POST "$SERVER_URL/api/files/$FILE_ID/externalTool/$TOOL_ID/toolUrl" \
curl -H "X-Dataverse-key:$API_TOKEN" -X POST "$SERVER_URL/api/files/$FILE_ID/externalTool/$TOOL_ID/toolUrl \

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.

a lost double quote?

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.

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.

fixed

@github-actions

This comment has been minimized.

@stevenwinship stevenwinship self-assigned this Oct 29, 2026
@stevenwinship stevenwinship removed their assignment Oct 29, 2026
@github-actions

This comment has been minimized.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
14.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@github-actions

Copy link
Copy Markdown

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:12760-previewers-not-working-with-guestbook-responses
ghcr.io/gdcc/configbaker:12760-previewers-not-working-with-guestbook-responses

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

This branch has not been deployed

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

Labels

FY27 Sprint 7 FY27 Sprint 7 (2026-09-23 - 2026-10-07) FY27 Sprint 8 FY27 Sprint 8 (2026-10-07 - 2026-10-21) Size: 30 A percentage of a sprint. 21 hours. (formerly size:33) Type: Bug a defect

Projects

Status: QA ✅

Development

Successfully merging this pull request may close these issues.

Previewers no longer working on files with required guestbooks, due to the API changes (since 6.10)

6 participants