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

Improved error reporting for redirected mistyped pins in board_connect_url #810

Closed
slodge opened this issue Nov 17, 2023 · 2 comments · Fixed by #811
Closed

Improved error reporting for redirected mistyped pins in board_connect_url #810

slodge opened this issue Nov 17, 2023 · 2 comments · Fixed by #811

Comments

@slodge
Copy link

slodge commented Nov 17, 2023

Disclaimer: I'm not sure whether I should log this with Connect rather than with pins-r

If I have a pin with a vanity url, but request that vanity url without a trailing slash, then I get a confusing error message about "Pin does not declare file type" - from

"Pin does not declare file type so can't be automatically read",

It might be helpful if this reported a message like "incorrect url - have you tried adding a trailing slash" instead - or perhaps it could even return the data?

Reproduced using:

library(pins)
board <- board_connect_url(
  list(
    mypin_works = "https://my.connect.com/test/data_cs/",
    mypin_not_works = "https://my.connect.com/test/data_cs"
  ),
  headers = connect_auth_headers(key = Sys.getenv("MY_KEY")))
)
data1 <- pin_read(board, "mypin_works")
data2 <- pin_read(board, "mypin_not_works")

If I look at the http transfer... I see that the "mypin_works" requests GET /test/data_cs/data.txt while "mypin_not_works" requests GET /test/data_cs which gets redirected to /test/data_cs/ which returns the Connect HTML page

httr::with_verbose({
  pin_read(board, "mypin_not_works")
}, data_in=TRUE, ssl=TRUE)

image

@slodge slodge changed the title Improved type reporting for redirects in board_connect_url Improved error reporting for redirected mistyped pins in board_connect_url Nov 17, 2023
@juliasilge
Copy link
Member

Ah, that's so unfortunate that this is the situation! Thanks for the report.

The board_url() infrastructure is very flexible and also allows for this kind of pin:

board <- board_url(c(
  letters = "https://raw.githubusercontent.com/rstudio/pins-r/master/tests/testthat/pin-files/first.txt"
))

This means we can't unfortunately remove a trailing slash because we can't know what the user is intending. However, we can make that error message better. 👍

Copy link

github-actions bot commented Dec 5, 2023

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants