Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion to check for valid api_key to avoid infinite loop #18

Open
rempsyc opened this issue Jun 18, 2023 · 0 comments
Open

Suggestion to check for valid api_key to avoid infinite loop #18

rempsyc opened this issue Jun 18, 2023 · 0 comments

Comments

@rempsyc
Copy link

rempsyc commented Jun 18, 2023

I am trying to setup a GitHub action to automate some steps using easyPubMed. I am facing some challenges with accessing the GitHub secret containing the environment variable for the PubMed API key.

Using Sys.getenv("API_TOKEN_PUBMED") will provide an empty string ("") if it cannot find it. If batch_pubmed_download() is provided this empty string in the api_key argument, it will get stuck in an infinite loop (Killing the request! Something is not working. Please, try again later), which is harder to debug from GitHub actions since we cannot see this message from a rendered rmarkdown file.

My suggestion is to error if api_key is empty:

if (`api_key` == "") stop("api_key cannot be an empty string.")

Reprex:

library(easyPubMed)
ml_query <- "Machine Learning[TI] AND 2016[PD]"
out1 <- batch_pubmed_download(pubmed_query_string = ml_query, batch_size = 500, api_key = "")
#> Killing the request! Something is not working. Please, try again later
#> Killing the request! Something is not working. Please, try again later
#> Killing the request! Something is not working. Please, try again later
[...]
#> Killing the request! Something is not working. Please, try again later
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

No branches or pull requests

1 participant