Skip to content

use httr2 for newBiocPkgDOI#75

Merged
LiNk-NY merged 5 commits into
develfrom
httr2_doi
May 7, 2026
Merged

use httr2 for newBiocPkgDOI#75
LiNk-NY merged 5 commits into
develfrom
httr2_doi

Conversation

@LiNk-NY

@LiNk-NY LiNk-NY commented Aug 18, 2025

Copy link
Copy Markdown
Collaborator

Hi Andres, @jwokaty

I don't have a Datacite account for testing the re-written generateBiocPkgDOI
function. Could you review and make sure that the changes work?

You can also share the details via bitwarden.

Thank you!

@LiNk-NY

LiNk-NY commented Aug 22, 2025

Copy link
Copy Markdown
Collaborator Author

@jwokaty
Note. This worked with when testing and generated a DOI at

https://handle.test.datacite.org/10.82962/b9.bioc.multiassayexperiment

@LiNk-NY
LiNk-NY force-pushed the httr2_doi branch 2 times, most recently from 0469acd to e7bdd2d Compare August 27, 2025 20:15
@LiNk-NY

LiNk-NY commented Feb 3, 2026

Copy link
Copy Markdown
Collaborator Author

Any updates on this @jwokaty ?
Thanks!

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 migrates the internal generateBiocPkgDOI() helper from httr to httr2 for creating DOIs via the DataCite REST API.

Changes:

  • Replaced the POST implementation with an httr2 request pipeline (request() + req_auth_basic() + JSON body + req_perform()).
  • Simplified response handling to extract data$id directly from resp_body_json().
  • Updated NAMESPACE imports to drop unused httr/stringr imports and add required httr2 imports.

Reviewed changes

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

File Description
R/newBiocPkgDOI.R Rewrites DOI creation request/response code to use httr2 instead of httr.
NAMESPACE Adjusts imports to align with the httr2-based implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/newBiocPkgDOI.R
Comment on lines +78 to +82
response <- request(base_url) |>
req_auth_basic(username, password) |>
req_headers("Content-Type" = "application/vnd.api+json") |>
req_body_json(payload) |>
req_perform()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

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.

Applied in c4041e7. Changed to req_body_json(payload, type = "application/vnd.api+json") so the vendor media type is set directly and not overwritten. Also removed the now-unused req_headers() call, dropped the stale jsonlite imports, and added resp_check_status() after req_perform() to surface HTTP errors clearly before parsing the response body.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for taking a look. The change removed the Content-Type header from the request by only using req_body_json. I have added it back in.

Comment thread R/newBiocPkgDOI.R
Comment on lines 83 to +84

if (response$status_code >= 200 && response$status_code < 300) {
response_text <- httr::content(response, "text")
response_json <- jsonlite::fromJSON(response_text)
return(response_json$data$id)
} else {
httr::message_for_status(response)
}
resp_body_json(response)$data$id

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

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.

This was already applied in c4041e7resp_check_status(response) is called on line 82, before parsing $data$id, so any authentication or validation failures surface as informative HTTP errors rather than a confusing parse failure.

Comment thread R/newBiocPkgDOI.R Outdated
@jwokaty

jwokaty commented May 7, 2026

Copy link
Copy Markdown
Contributor

@LiNk-NY I'm sorry I missed this multiple times. I can review when I return next week.

LiNk-NY and others added 3 commits May 7, 2026 14:01
- Add resp_check_status() to surface HTTP errors before parsing body
- Update NAMESPACE to add resp_check_status import

Agent-Logs-Url: https://github.com/seandavi/BiocPkgTools/sessions/449565a2-c285-4206-8041-f299c3adb2c5

Co-authored-by: seandavi <92435+seandavi@users.noreply.github.com>
@LiNk-NY
LiNk-NY merged commit a01b39c into devel May 7, 2026
4 checks passed
@LiNk-NY
LiNk-NY deleted the httr2_doi branch May 7, 2026 18:19
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.

5 participants