Skip to content

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

@rempsyc

Description

@rempsyc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions