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

BUG: fetch_all throws error on aliases_list API function #223

Open
sahilds1 opened this issue Jan 27, 2020 · 3 comments
Open

BUG: fetch_all throws error on aliases_list API function #223

sahilds1 opened this issue Jan 27, 2020 · 3 comments
Labels

Comments

@sahilds1
Copy link
Contributor

template_alias_objects <- fetch_all(aliases_list,object_type='template_script')

Produces:

Error in if (any(sapply(res, .until))) { : missing value where TRUE/FALSE needed

Stepping through the relevant code in pagination_helpers.R:

res <- do.call(aliases_list, list(object_type='template_script'))

str(res)
List of 23
 $ :List of 6
  ..$ id         : int 11
  ..$ objectId   : int 12367
  ..$ objectType : chr "template_script"
  ..$ alias      : chr "civis-ShapefileExport"
  ..$ userId     : int 3001
  ..$ displayName: chr "Export Shapefile"

.until = function(x) x == FALSE

sapply(res, .until)
             [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]  [,9] [,10] [,11]
id          FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
objectId    FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
objectType     NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA
alias          NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA
userId      FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
displayName    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA


any(sapply(res, .until))
[1] NA

@sahilds1
Copy link
Contributor Author

sahilds1 commented Jan 27, 2020

I think we can fix this bug either by

  1. Setting the na.rm argument to the any function to TRUE.
any(sapply(res, .until),na.rm=TRUE)
[1] FALSE
  1. Could we change the value of .until = function(x) x == FALSE in fetch_all (link) to avoid the creation of the NAs in the first place?

@patr1ckm
Copy link
Contributor

Thanks for the report! This is really helpful.

In this case:

fetch_until(aliases_list, limit=1000, object_type='template_script', function(x) length(x) == 0))

Would do the trick without a code change.

For the fix, it's likely that option 1 is fine. Option 2 would be great to have. We'd want to surface .until as an argument with the current default as the default value.

@sahilds1
Copy link
Contributor Author

Thank you! For this PR #221 I used the fetch_until(aliases_list, limit=1000, object_type='template_script', function(x) length(x) == 0)) per your suggestion.

To address this bug do you recommend creating a new Jira ticket and opening a PR? It's not immediately obvious to me how to do Option 2. Would using Option 1 suffice? If not, I'm happy to dig into how to do Option 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants