8000 Ungraceful fail condition on 206 error · Issue #27 · ropensci/worrms · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Ungraceful fail condition on 206 error #27

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

Open
jebyrnes opened this issue Nov 14, 2021 · 3 comments
Open

Ungraceful fail condition on 206 error #27

jebyrnes opened this issue Nov 14, 2021 · 3 comments

Comments

@jebyrnes
Copy link

Hello! Loving this package, as taxize doesn't get synonyms from WORMS that I can tell.

But - I'm running into a funny problem. wm_name2id will often return a 206 error.

library(worrms)

wm_records_name("Asterias rubens")

Error: (206) Partial Content - Asterias rubens

This is odd, as I whipped up a function to do an endrun around the problem, and it works fine

library(dplyr)


get_id <- function(.x){
  
  rec <- try(wm_records_name(.x))
  if(class(rec) == "try-error"){return(NA)}
  
  rec %>%
    filter(status=="accepted") %>%
    pull(AphiaID) 
}

What's going on here? And/or if this is an api, not a package problem, could something like the function I wrote above be a good workaround fail condition?

Here it is without dplyr - and, again, this would only happen if a 206 error was thrown, and I'm guessing a more graceful failure condition (if there are no records) could be added - although if it's a 206, there should be some records.

get_id <- function(.x){
  
  rec <- try(wm_records_name(.x))
  if(class(rec) == "try-error"){return(NA)}
  
  acc <- subset(rec, rec$status=="accepted")
  acc$AphiaID[1]
}
@bart-v
Copy link
Collaborator
bart-v commented Jun 21, 2023

Feel free to make a PR

@bart-v bart-v mentioned this issue Jun 21, 2023
@LuisEnriqueAngelesGonzalez

Hello, I tried to make a loop for downloading species data. However, I found the same problem. I do not understand why is this happening? Is there a way to solve this problem?

@bart-v
Copy link
Collaborator
bart-v commented May 28, 2024

Yes, the function wm_name2id() needs to be fixed to handle the HTTP 206 reply
It indicates several matches for one single name.

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

No branches or pull requests

3 participants
0