-
Notifications
You must be signed in to change notification settings - Fork 52
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
Handle missingness #84
Comments
Related to #21 (which is a pretty old issue, perhaps unhelpfully old) |
Reading #21 (comment), it seems like the goal should be to trigger an error in the endpoint instead of silently removing the missingness components as-is described above. So, the following should be added: param_names = names(params)
missingness_params = param_names[sapply(params, function(x) is.null(x) || is.na(x)]
if(length(missingness_params) > 0) {
msg = paste("Parameters must not have `NA` or `NULL` as their values.",
"The following parameters were detected to have some level of missingness: \n"
paste0(missingness_params, collapse = "\n"))
stop(msg, call. = FALSE)
} Though, that leaves the case brought up in coatless-rpkg/ghapi3#3 that requires flexibility of defined parameters to act as optional criteria missingness. I suppose the best way to handle this is to retrieve only valid parameters prior to the valid_params = function(...) {
params = list(...)
params = Filter(Negate(is.null), params)
params = Filter(Negate(is.na), params)
params
}
repo_transfer = function(owner, repo, new_owner, team_id = NA) {
params = valid_params(endpoint = "custom endpoint here", owner = owner, repo = repo, new_owner = new_owner, team_id = team_id)
params
## Call the gh function dynamically with the subset of parameters potentially
# do.call(gh, params)
} |
I bypassed that here using a combination of:
Each param's default is NULL. Then it is passed to:
|
I am planning to fix this by
Non-named parameters are not touched, since they go into the request body, they will be JSON encoded, and |
@gaborcsardi awesome. Do you have an ETA on when the next version of |
today |
Consider the use of
NA
andNULL
being 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.R
to remove parameters that have R-specific missingness? e.g.The text was updated successfully, but these errors were encountered: