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

Non-Proxy hosts with wildcards are incorrectly passed to npm #1172

Open
StefanBauerTT opened this issue Jan 30, 2025 · 6 comments
Open

Non-Proxy hosts with wildcards are incorrectly passed to npm #1172

StefanBauerTT opened this issue Jan 30, 2025 · 6 comments

Comments

@StefanBauerTT
Copy link

StefanBauerTT commented Jan 30, 2025

Steps to reproduce

  • Configure a maven proxy with a wildcard non proxy hosts, e.g. *.google.de (see DefaultNpmRunnerTest.java)

Expected result

  • npm is called with --noproxy=*.google.de

Actual result

  • npm is called with --noproxy=.google.de. The asterisk is missing. npm does not understand this syntax.

Analysis

@eirslett
Copy link
Owner

eirslett commented Jan 30, 2025

@tkalmar do you remember any of this?

@tkalmar
Copy link
Contributor

tkalmar commented Jan 30, 2025

short test:

npm config set https-proxy https://proxy.example.com:1337
npm show lodash    --registry=https://registry.npmjs.org/ <-- timeout
npm show lodash    --registry=https://registry.npmjs.org/ --noproxy=.npmjs.org <-- works
npm show lodash    --registry=https://registry.npmjs.org/ --noproxy=*.npmjs.org <-- timeout

so i can't confirm that npm does not understand this syntax

@StefanBauerTT
Copy link
Author

StefanBauerTT commented Jan 30, 2025

Thank you for your swift response, @eirslett and @tkalmar. I missed a piece of the puzzle. The error occurred when running npm install. Our package.json contains a dependency with explicit git hostname like:

{
  "devDependencies": {
    "privateLib": "git+https://git.corp.network/privateLib.git#main"
  }
}

Error message was:

[INFO] Found proxies: [httpsproxy{protocol='https', host='proxy.corp.network', port=8080, nonProxyHosts='*.corp.network'}]
[INFO] npm error code 128
[INFO] npm error An unknown git error occurred
[INFO] npm error command git --no-replace-objects ls-remote https://git.corp.network/privateLib.git
[INFO] npm error fatal: unable to access 'https://git.corp.network/privateLib.git': Received HTTP code 503 from proxy after CONNECT

I had to explicitly add git.corp.network to the maven non-proxy hosts to make this work. (Note from the future: It did not fix it)

I tried calling npm install --noproxy=*.corp.network and it also fails. So I was wrong with my guess that the asterisk is missing. Thanks for pointing that out. So this is a bug in npm itself?

@tkalmar
Copy link
Contributor

tkalmar commented Jan 30, 2025

@StefanBauerTT
I don't think that npm passes the proxy config to the git client. you could try to configure a no_proxy environment variable which should be used by git (i think also without *) So i think

<configuration>
    <environmentVariables>
        <no_proxy>.corp.network</no_proxy>
    </environmentVariables>        
</configuration>

should work.

@StefanBauerTT
Copy link
Author

I found the place where the proxy settings get passed from the frontend plugin to git via environment variables:

proxyEnvironmentVariables.put("https_proxy", proxy.getUri().toString());

Surprisingly though, the no_proxy environment variable is not set here, so right now I don't understand how adding git.corp.network to the <nonProxyHosts> of my maven settings.xml fixed the issue.

@StefanBauerTT
Copy link
Author

StefanBauerTT commented Jan 31, 2025

Ok, sorry for the confustion. Adding git.corp.network to the <nonProxyHosts> in the maven settings.xml acutally fixed nothing.

So the bottom line of this is that the frontend plugin sets the https_proxy but not the no_proxy environment variable. One could argue that this is inconsistent and can lead to confusing errors, just like the one I experienced.

I will leave it up to you if you consinder this a bug worth fixing or close this ticket with reference to @tkalmar 's workaround from #1172 (comment) . Thank you for your time.

tkalmar added a commit to tkalmar/frontend-maven-plugin that referenced this issue Feb 9, 2025
tkalmar added a commit to tkalmar/frontend-maven-plugin that referenced this issue Feb 9, 2025
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

3 participants