Skip to content

Update expected paths in use_rscloud_badge() #1670

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

Closed
gvelasq opened this issue Sep 10, 2022 · 0 comments · Fixed by #1831
Closed

Update expected paths in use_rscloud_badge() #1670

gvelasq opened this issue Sep 10, 2022 · 0 comments · Fixed by #1831
Labels
bug an unexpected problem or unintended behavior readme 🏠 Readme, badges, ...
Milestone

Comments

@gvelasq
Copy link
Contributor

gvelasq commented Sep 10, 2022

I recently learned that the default paths for RStudio Cloud projects, both for individual projects and for projects inside shared spaces, have been changed such that the word content is now used instead of project in the path. As far as I can tell, this is an undocumented change.

# old
https://rstudio.cloud/project/<project-id>
https://rstudio.cloud/spaces/<space-id>/project/<project-id>

# new
https://rstudio.cloud/content/<project-id>
https://rstudio.cloud/spaces/<space-id>/content/<project-id>

This is a breaking change for the function I contributed in #1584 and #1589, use_rscloud_badge(), which expects that paths passed via the url argument will include project. While valid paths that use project will be redirected by RStudio Cloud to the same path using content instead, all new paths obtained from RStudio Cloud, via the dropdown (...) > Share Project Link or from copy/pasting the URL, will use content and thus will cause use_rscloud_badge() to return an error:

library(httr2)
library(usethis)
library(withr)

# 1. define helper function ----
check_rscloud_url <- function(url) {
  req_perform(request(url))
}

# 2. confirm 'project' containing url is a valid url ----
project_url <- "https://rstudio.cloud/project/3584129"
check_rscloud_url(project_url)
#> <httr2_response>
#> GET https://rstudio.cloud/project/3584129
#> Status: 200 OK
#> Content-Type: text/html
#> Body: In memory (643 bytes)

# 3. confirm 'content' containing url is a valid url ----
content_url <- "https://rstudio.cloud/content/3584129"
check_rscloud_url(content_url)
#> <httr2_response>
#> GET https://rstudio.cloud/content/3584129
#> Status: 200 OK
#> Content-Type: text/html
#> Body: In memory (643 bytes)

# 4. confirm use_rscloud_badge(content_url) returns an error ----
with_tempdir({
  create_project(tempdir())
  use_readme_md()
  use_rscloud_badge(content_url)
})
#> ✔ Setting active project to '/private/var/folders/qf/
#> yt27gctx33x4pvc255t0w9zc0000gp/T/RtmpggYsT7'
#> ✔ Creating 'R/'
#> ✔ Writing a sentinel file '.here'
#> • Build robust paths within your project via `here::here()`
#> • Learn more at <https://here.r-lib.org>
#> ✔ Setting active project to '<no active project>'
#> ✔ Setting active project to '/private/var/folders/qf/yt27gctx33x4pvc255t0w9zc0000gp/T/RtmpggYsT7'
#> ✔ Writing 'README.md'
#> Error: `usethis::use_rscloud_badge()` requires a link to an existing RStudio Cloud project of the form 'https://rstudio.cloud/project/<project-id>' or 'https://rstudio.cloud/spaces/<space-id>/project/<project-id>'.

Created on 2022-09-09 with reprex v2.0.2

This would be a relatively easy fix and I'd be happy to submit a PR if helpful. One question for the maintainers would be, since paths that contain project are still technically valid URLs, should we soft deprecate the use of paths containing project or should we require that all paths use content moving forward?

@jennybc jennybc added bug an unexpected problem or unintended behavior readme 🏠 Readme, badges, ... labels Sep 10, 2022
@jennybc jennybc added this to the v2.2.0 milestone Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior readme 🏠 Readme, badges, ...
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants