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

Some RStudio help links return 404 errors #156

Open
paulkm opened this issue Oct 28, 2024 · 0 comments
Open

Some RStudio help links return 404 errors #156

paulkm opened this issue Oct 28, 2024 · 0 comments
Labels

Comments

@paulkm
Copy link

paulkm commented Oct 28, 2024

Bug description

Creating an issue for tracking/discussion - I will submit a PR as well.

Within the RStudio package help pane, links to other help topics will sometimes return a 404 instead of the target help page. The target help page(s) do exist, and can be accessed by navigating from the main help nav. Investigating the issue, the root cause appears to be that the R help system will sometimes return a 302 response with a relative filename in the location header, which the rewrite_netloc function in rsession-proxy prepends the host:port onto resulting in an invalid URL.

An example request and response:

GET /rstudio/help/library/base/help/conditions HTTP/1.1
Host: 127.0.0.1:8888
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:131.0) Gecko/20100101 Firefox/131.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br, zstd
Connection: keep-alive
Referer: http://127.0.0.1:8888/rstudio/
Cookie: --removed--
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: iframe
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
Priority: u=4

With the following response:

HTTP/1.1 302 Moved Temporarily
Content-Type: text/html
Location: //127.0.0.1:8888/../../base/html/conditions.html
Date: Mon, 28 Oct 2024 16:14:55 GMT
X-Content-Type-Options: nosniff
Server: RStudio
Content-Length: 75

The browser then attempts to follow that URL with the following results:

GET /base/html/conditions.html HTTP/1.1
Host: 127.0.0.1:8888
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:131.0) Gecko/20100101 Firefox/131.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br, zstd
Referer: http://127.0.0.1:8888/rstudio/
Connection: keep-alive
Cookie: --removed--
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: iframe
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
Priority: u=4

Returning:

HTTP/1.1 404 Not Found
Server: TornadoServer/6.4.1
Content-Type: text/html
Date: Mon, 28 Oct 2024 16:14:55 GMT
X-Content-Type-Options: nosniff
Content-Security-Policy: frame-ancestors 'self'; report-uri /api/security/csp-report
Content-Length: 3034

The relative portion of the above URL should have been applied to the original request filename, and pointed to the correct location here: http://127.0.0.1:8888/rstudio/help/library/base/html/conditions.html

How to reproduce

  1. Launch RStudio
  2. Go to R console pane
  3. Input ?later::run_now, and <enter>
  4. Note that the help page opens, go to the help pane, scroll down, and click the link inside that page for tryCatch

Expected behaviour

After step 3 4 above, the help topic for 'Condition Handling and Recovery' should have been opened in the help page.

Actual behaviour

The help pane displays the Jupyter server's built in 404 page.

Your personal set up

Running RStudio Server 2024.09.0 Build 375 from Docker container at localhost port 8888.

The following Dockerfile will repro this issue:

ARG BASE_CONTAINER=quay.io/jupyter/r-notebook:hub-5.2.1
FROM $BASE_CONTAINER

# install rstudio-server
USER root

# http://cran.rstudio.com/bin/linux/ubuntu/
RUN apt-get update -qq && \
   apt-get install --no-install-recommends software-properties-common dirmngr  -y && \
   wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc && \
   add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" && \
   apt install --no-install-recommends r-base -y

# Per: https://posit.co/download/rstudio-server/
RUN apt-get update && \
    apt-get install gdebi-core libproj-dev proj-data proj-bin libgeos-dev build-essential libfreetype6-dev libfontconfig1-dev cmake -y && \
    curl --silent -L --fail wget wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2024.09.0-375-amd64.deb > /tmp/rstudio.deb && \
    echo 'efcc1c69252dd220b30973c7a10571707cfd47afc70c37c11a5e68efd2129feb  /tmp/rstudio.deb' | shasum -a 256 -c - && \
    gdebi -n /tmp/rstudio.deb && \
    rm /tmp/rstudio.deb && \
    apt-get clean

USER $NB_USER

RUN pip install jupyter-rsession-proxy

# To see the fix I propose, comment out the line above and uncomment the line below:
# RUN pip install git+https://github.com/paulkm/jupyter-rsession-proxy.git@fix-help-links-bug

# To build (with Docker): docker build -t rstudio-test .
# To run: docker run -p 8888:8888 rstudio-test
# The console output will display the localhost URL to use
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

1 participant