Consider the use of NA and NULL being passed into a named parameter:
gh("/repos/:owner/:repo/issues", owner = "r-lib", repo = "gh", state = NULL)
# Error in gsub(paste0(":", n, "\\b"), p, endpoint) :
# invalid 'replacement' argument
gh("/repos/:owner/:repo/issues", owner = "r-lib", repo = "gh", state = NA)
# Error in gh("/repos/:owner/:repo/issues", owner = "r-lib", repo = "gh", :
# GitHub API error (422): 422 Unprocessable Entity
# Validation Failed
This is a bit problematic for parameters that may be optional. (c.f. coatless-rpkg/ghapi3#3)
Would it be possible to add filtering inside of gh_set_endpoint() in R/gh_request.R to remove parameters that have R-specific missingness? e.g.
gh_set_endpoint <- function(x) {
params <- x$params
if (!grepl(":", x$endpoint) || length(params) == 0L || has_no_names(params)) {
return(x)
}
# Subset out invalid params
params <- Filter(Negate(is.null), params)
params <- Filter(Negate(is.na), params)
# rest of the logic ...
}
Consider the use of
NAandNULLbeing passed into a named parameter:This is a bit problematic for parameters that may be optional. (c.f. coatless-rpkg/ghapi3#3)
Would it be possible to add filtering inside of
gh_set_endpoint()inR/gh_request.Rto remove parameters that have R-specific missingness? e.g.