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

fix(gomod): GOPROXY with slash doesnt work #32255

Merged
merged 3 commits into from
Nov 4, 2024

Conversation

PhilipAbed
Copy link
Collaborator

Changes

trimm slash while parsing GOPROXY

Context

some customer run failed with this error
DEBUG: Goproxy error: trying next URL provided with GOPROXY

the URL in the error had 2 slashes // after go.
"url": "https://{XYZ.ARTIFACTORY}/go//x/y/z/v3/@v/list",

when i checked code for this i found the slash is hardcoded into this

const url = `${baseUrl}/${this.encodeCase(packageName)}/@v/list`;

the simple solution is to trim the slash from GOPROXY in the parser before it, as it is not necessary.

let me know if you think otherwise.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

Copy link
Collaborator

@rarkins rarkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a trailing slash a problem if parsed with it? It's valid in URLs obviously

Copy link
Collaborator

@rarkins rarkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this approach to fixing it is not robust. It's done in a separate file to where the problem occurs. We should either use a better way of joining URLs, or do the trailing slash trimming at the point of static joining

@PhilipAbed
Copy link
Collaborator Author

so you are saying the issue is with
const url = ${baseUrl}/${this.encodeCase(packageName)}/@v/list;
its kind of hardcoded, we should use some URL joiner here

@viceice
Copy link
Member

viceice commented Nov 3, 2024

so you are saying the issue is with
const url = ${baseUrl}/${this.encodeCase(packageName)}/@v/list;
its kind of hardcoded, we should use some URL joiner here

yes, that's better

@PhilipAbed
Copy link
Collaborator Author

PhilipAbed commented Nov 4, 2024

im afraid to use url joiner since the url.parser and joiner are broken if set without protocol.

discussion: #30295

i haven't seen any docs indicating that the URLS set in GOPROXY can be without a protocol like https:// .. etc, so i think its ok

@PhilipAbed PhilipAbed requested a review from rarkins November 4, 2024 14:11
@rarkins rarkins added this pull request to the merge queue Nov 4, 2024
Merged via the queue into renovatebot:main with commit 80dd936 Nov 4, 2024
39 checks passed
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 39.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2024
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 this pull request may close these issues.

4 participants