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

redirect mode prepends pathPrefix to redirected URL, causing errors #2028

Open
chennin opened this issue Jan 25, 2025 · 0 comments
Open

redirect mode prepends pathPrefix to redirected URL, causing errors #2028

chennin opened this issue Jan 25, 2025 · 0 comments

Comments

@chennin
Copy link

chennin commented Jan 25, 2025

Describe the bug
With ATHENS_PATH_PREFIX and mode = "redirect" set, the redirected URL includes the path prefix, which is probably invalid.

Error Message

bad request: invalid escaped module path "go/github.com/openshift/api": malformed module path "go/github.com/openshift/api": missing dot in first path element

where "/go" is my path prefix

To Reproduce

Set up Athens with a path prefix, I am using ATHENS_PATH_PREFIX: "/go"

Set a download mode file such as

mode = "sync"
downloadURL = "https://proxy.golang.org"
download "github.com/openshift/api" {
  mode = "redirect"
  downloadURL = "https://proxy.golang.org"
}

with GOPROXY set to the Athens, run go mod download github.com/openshift/[email protected]+incompatible

or, curl the URL
$ curl -Lv "http://MY_ATHENS_HOST/go/github.com/openshift/api/@v/v3.9.0+incompatible.info"

* Host MY_ATHENS_HOST:80 was resolved.
* IPv6: (none)
* IPv4: 10.0.1.3
*   Trying 10.0.1.3:80...
* Connected to MY_ATHENS_HOST (10.0.1.3) port 80
* using HTTP/1.x
> GET /go/github.com/openshift/api/@v/v3.9.0+incompatible.info HTTP/1.1
> Host: MY_ATHENS_HOST
> User-Agent: curl/8.11.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 301 Moved Permanently
< Server: nginx
< Date: Sat, 25 Jan 2025 04:14:43 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 0
< Connection: keep-alive
< Location: https://proxy.golang.org/go/github.com/openshift/api/@v/v3.9.0+incompatible.info ### <-- includes pathprefix which won't be valid
* Ignoring the response-body
* setting size while ignoring
<
* Connection #0 to host MY_ATHENS_HOST left intact
* Clear auth, redirects to port from 80 to 443
* Issue another request to this URL: 'https://proxy.golang.org/go/github.com/openshift/api/@v/v3.9.0+incompatible.info'
* Host proxy.golang.org:443 was resolved.
* IPv6: 2607:f8b0:4006:809::2011
* IPv4: 142.250.80.113
*   Trying [2607:f8b0:4006:809::2011]:443...
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: none
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / x25519 / id-ecPublicKey
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=misc-sni.google.com
*  start date: Jan  6 08:36:24 2025 GMT
*  expire date: Mar 31 08:36:23 2025 GMT
*  subjectAltName: host "proxy.golang.org" matched cert's "*.golang.org"
*  issuer: C=US; O=Google Trust Services; CN=WR2
*  SSL certificate verify ok.
*   Certificate level 0: Public key type EC/prime256v1 (256/128 Bits/secBits), signed using sha256WithRSAEncryption
*   Certificate level 1: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
*   Certificate level 2: Public key type RSA (4096/152 Bits/secBits), signed using sha384WithRSAEncryption
* Connected to proxy.golang.org (2607:f8b0:4006:809::2011) port 443
* using HTTP/2
* [HTTP/2] [1] OPENED stream for https://proxy.golang.org/go/github.com/openshift/api/@v/v3.9.0+incompatible.info
* [HTTP/2] [1] [:method: GET]
* [HTTP/2] [1] [:scheme: https]
* [HTTP/2] [1] [:authority: proxy.golang.org]
* [HTTP/2] [1] [:path: /go/github.com/openshift/api/@v/v3.9.0+incompatible.info]
* [HTTP/2] [1] [user-agent: curl/8.11.1]
* [HTTP/2] [1] [accept: */*]
> GET /go/github.com/openshift/api/@v/v3.9.0+incompatible.info HTTP/2
> Host: proxy.golang.org
> User-Agent: curl/8.11.1
> Accept: */*
>
* Request completely sent off
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
< HTTP/2 404
< access-control-allow-origin: *
< content-security-policy-report-only: script-src 'none'; form-action 'none'; frame-src 'none'; report-uri https://csp.withgoogle.com/csp/goa-fa2dfb7c_2
< content-type: text/plain; charset=UTF-8
< cross-origin-opener-policy: same-origin
< vary: Sec-Fetch-Site
< vary: Sec-Fetch-Mode
< vary: Sec-Fetch-Dest
< x-content-type-options: nosniff
< x-frame-options: SAMEORIGIN
< x-xss-protection: 0
< date: Sat, 25 Jan 2025 04:14:44 GMT
< content-length: 158
< alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
<
* Connection #1 to host proxy.golang.org left intact
bad request: invalid escaped module path "go/github.com/openshift/api": malformed module path "go/github.com/openshift/api": missing dot in first path element

Expected behavior
Athens redirects to a URL without my local path prefix

Environment (please complete the following information):

  • OS: Linux 64bit
  • Go version : go1.23.5
  • Proxy version : v0.15.4
  • Storage :fs

Additional information

Attempting to work around a retracted tag openshift/api#1661 where sync does not work

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

No branches or pull requests

1 participant