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

Rsconnect unable to write new pin #534

Closed
joelgsponer opened this issue Oct 13, 2021 · 12 comments
Closed

Rsconnect unable to write new pin #534

joelgsponer opened this issue Oct 13, 2021 · 12 comments

Comments

@joelgsponer
Copy link

Hi,
Many thanks for your work I really like the ease of use of the pins package. Unfortunately, the recent update did introduce some headaches for me. I use the pins package to temporarily store some data on our company reconnect instance. Until now this worked perfectly. But now I am unable to write/create new pins.
I am able to connect to the board without problems.

board <- pins::board_rsconnect(auth = "envvar")  #This works and I do see the present pins.
pins::pin_write(board, mtcars, "test")

but writing the pin results in a 404 error.
Error in rsc_check_status(req) : Not Found (HTTP 404).

Digging into the code I think the issue might be here:

#' @export
pin_store.pins_board_rsconnect <- function(
   ...
{
  # [...]
  # Find/create content item
  content_guid <- tryCatch(
    {
      guid <- rsc_content_find(board, name, warn = FALSE)$guid
      rsc_content_update(board, guid, metadata, access_type = access_type)
      guid
    },
    pins_pin_missing = function(e) {
      rsc_content_create(board, name, metadata, access_type = access_type)$guid
    }
  )

As I understand it should try to find the pin and if not it expects the pins_pin_missing error.
But this never happens as rsc_content_find throws a 404 error before.

rsc_content_find <- function(board, name, version = NULL, warn = TRUE) {
 #[...]
  # https://docs.rstudio.com/connect/api/#get-/v1/content
  json <- rsc_GET(board, "v1/content", list(name = name$name))
  if (length(json) == 0) {
    abort_pin_missing(name$name)
  }

So I never get to the pin creation part.
Is this behavior on purpose? Should the response of the server upon GET be different (e.g. {})?
Thanks
Joël

@joelgsponer
Copy link
Author

Ok, unfortunately after forking and changing the code to arrive at pin create I still get a 404.
What is different in the API call from the previous version that makes it break now?
I do not understand how I can connect to the board and see the pins but not GET or POST content.
Many thanks
Joël

@joelgsponer
Copy link
Author

Inspecting our Instance I see:
RStudio Connect API Reference 1.0.1
Build 1.8.4.2-2

@dewoller
Copy link

@joelgsponer , where did you find the instance information?

@joelgsponer
Copy link
Author

@dewoller I found it in the documentation:
image
Under the API Reference section.

@hadley
Copy link
Member

hadley commented Oct 18, 2021

@dewoller it should also print the version when you run board_rsconnect()

@sellorm
Copy link
Contributor

sellorm commented Nov 5, 2021

@joelgsponer If you're seeing the rsc_check_status/rsc_content_find 404 error, it might be worth checking to see if you have anything like a reverse proxy or Web Application Firewall in front of Connect that may be causing an issue.

We saw something similar in #539, which turned out to be a WAF rule blocking certain types of API request.

@hadley
Copy link
Member

hadley commented Nov 16, 2021

This doesn't seem to be a widespread problem, and I can't reproduce so I'm going to close.

@hadley hadley closed this as completed Nov 16, 2021
@j-andrews7
Copy link

We are having this same issue - cannot read old pins nor write new ones with pins 1.0.0 or dev version with RSC 1.8.4.2-2. I am presuming this is the same issue as #539, but I don't have access to the RSC server to determine what's wrong.

Just adding that there will likely be more reports of this over time as more people update things.

@hadley
Copy link
Member

hadley commented Dec 15, 2021

@j-andrews7 I'd recommend upgrading to pins 1.0.1 (released yesterday) and then if you have another problem please file a new issue with reprex/traceback.

@saadaslam
Copy link

I did some research here, and I think it depends on the setup of your RStudio Connect instance as I'm having the same issue. I think there may be something with the instance where the API isn't enabled. The URL that httr queries is effectively something like https://my.rsc.com/__api__/v1/content?name=my-data. Typing that into my browser, I get a 404 error.

@sellorm
Copy link
Contributor

sellorm commented Mar 14, 2022

For anybody finding this thread later, one of the Connect APIs that pins uses, /v1/content, was only introduced in Connect 1.8.6. Prior to that, it was an experimental API and so was not stable or available on the same path.

Anybody else encountering the same issue should consider upgrading their Connect instance.

@github-actions
Copy link

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 Aug 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants