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

[BUG] HTTP_PROXY Support No Longer Works #714

Closed
mdgilene opened this issue Oct 11, 2023 · 6 comments · Fixed by #762 · May be fixed by vAHiD55555/generative-ai#3
Closed

[BUG] HTTP_PROXY Support No Longer Works #714

mdgilene opened this issue Oct 11, 2023 · 6 comments · Fixed by #762 · May be fixed by vAHiD55555/generative-ai#3
Assignees
Labels
bug Something isn't working released

Comments

@mdgilene
Copy link

🐛 Bug Report:

Describe the bug

This commit which swapped to a new HttpModule implementation completely removed the ability to use the CLI behind any kind of proxy.

66b78ff

Expected behavior

HttpModule is configured with HTTP_PROXY, HTTPS_PROXY, and NO_PROXY

@mdgilene mdgilene added the bug Something isn't working label Oct 11, 2023
@wing328
Copy link
Member

wing328 commented Oct 15, 2023

@mdgilene thanks for reporting the issue.

@keks42 is that something you can take a look when you've time?

@keks42
Copy link
Contributor

keks42 commented Oct 19, 2023

@wing328 Thanks for highlighting me, I can try, but unfortunately I could not reproduce the problem :(

@mdgilene Thanks for reporting the issue.

I tried to reproduce it, but for me everything seems to work fine. Here is what I did:
I locally started a proxy server [1] that just logs & forwards everything. Then I started some minimum working example, I just checked out some project using this library [2]. The project uses openapi-generator-cli in an older version, so I upgraded it to use 2.7.0. Without configuring any proxy stuff that project worked fine. There were no connections shown in the proxy.

Then I proceeded to set the proxy environment:
$ export HTTP_PROXY=http://localhost:1080
$ export HTTPS_PROXY=http://localhost:1080

I removed the node_modules in that project to have a clean start again and executed the generation task again npm run generate:api. It worked fine and on my proxy there were 2 requests shown trying to connect mavencentral to download the openapi jar. I got a 501 because the local proxy forwarded the actual https request as http, but that is an issue of my local proxy configuration - the openapi-generator-cli did use the proxy.
Then I added the downloadUrl to use my companies own maven-repository (which still does accept http calls unlike mavenCentral) and that worked fine. The requests were shown in the proxy logs and the jar was downloaded & executed.

Long story short: What can I do to reproduce your error?

[1] https://www.mock-server.com/mock_server/mockserver_ui.html
[2] https://github.com/kevinboosten/angular-openapi-demo

@ShellCode33
Copy link

ShellCode33 commented Oct 31, 2023

I'm facing the same issue, openapi-generator-cli is not using the proxy, therefore it is unable to download the jar file from maven.

This might be related: axios/axios#2072

EDIT: it might actually be related to the HTTP method used to go through the proxy. If you use a proxy that simply forwards requests it will work (for http, not for https), but if your proxy relies on the CONNECT method and denies other methods (which is usually how corporate proxies work), it won't work.

The workaround seems to be:

const HttpsProxyAgent = require('https-proxy-agent');

const axiosDefaultConfig = {
    baseURL: 'https://domain.tld/api',
    proxy: false,
    httpsAgent: new HttpsProxyAgent('http://127.0.0.1:8080')
};

Of course the HTTPS_PROXY environment variable should be used.

jontze added a commit to jontze/openapi-generator-cli that referenced this issue Mar 5, 2024
@jontze
Copy link
Contributor

jontze commented Mar 5, 2024

I ran into this issue as well. Based on what @ShellCode33 pointed out ( #714 (comment) ) and the initial implementation 66b78ff , I was able to resolve it with the following code:

// apps/generator-cli/src/app/app.module.ts
import { HttpsProxyAgent } from 'https-proxy-agent';

const proxyUrl = process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
const httpModuleConfig: HttpModuleOptions = {};

if (proxyUrl) {
  httpModuleConfig.proxy = false;
  httpModuleConfig.httpsAgent = new HttpsProxyAgent(proxyUrl);
}

@Module({
  imports: [
    HttpModule.register({
      ...httpModuleConfig,
    }),
  ],
  // ...
})
export class AppModule implements OnApplicationBootstrap {
 // ...
}

However, I just noticed that there's also a draft pull request with a similar approach: #752 . I'm thinking about opening another PR, but unfortunately I'm not that deep into proxies and not too sure if my implementation might break things... 😅

@wing328
Copy link
Member

wing328 commented Mar 6, 2024

please open a PR to start with and we'll start from there.

jontze added a commit to jontze/openapi-generator-cli that referenced this issue Mar 6, 2024
jontze added a commit to jontze/openapi-generator-cli that referenced this issue Apr 15, 2024
wing328 pushed a commit that referenced this issue Apr 16, 2024
* chore(deps): install `https-proxy-agent` as dependency

* fix(app): configure http agent with proxy url if present in environment

Fixes ##714
Copy link

🎉 This issue has been resolved in version 2.13.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

renovate bot added a commit to ScaleLeap/selling-partner-api-sdk that referenced this issue Apr 16, 2024
… v2.13.2 (#1045)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[@openapitools/openapi-generator-cli](https://togithub.com/OpenAPITools/openapi-generator-cli)
| [`2.13.1` ->
`2.13.2`](https://renovatebot.com/diffs/npm/@openapitools%2fopenapi-generator-cli/2.13.1/2.13.2)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@openapitools%2fopenapi-generator-cli/2.13.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@openapitools%2fopenapi-generator-cli/2.13.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@openapitools%2fopenapi-generator-cli/2.13.1/2.13.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@openapitools%2fopenapi-generator-cli/2.13.1/2.13.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>OpenAPITools/openapi-generator-cli
(@&#8203;openapitools/openapi-generator-cli)</summary>

###
[`v2.13.2`](https://togithub.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.2)

[Compare
Source](https://togithub.com/OpenAPITools/openapi-generator-cli/compare/v2.13.1...v2.13.2)

##### Bug Fixes

- **app:** configure http with proxy url if present in environment
([#&#8203;762](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/762))
([7787f07](https://togithub.com/OpenAPITools/openapi-generator-cli/commit/7787f07edfe5a9d8d5272646bf54311a31c89e62)),
closes
[OpenAPITools/openapi-generator-cli#714](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/714)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "every weekday" in timezone Etc/UTC,
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/ScaleLeap/selling-partner-api-sdk).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yOTMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI5My4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbInJlbm92YXRlYm90Il19-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Hinton pushed a commit to bitwarden/sdk that referenced this issue May 14, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[@openapitools/openapi-generator-cli](https://togithub.com/OpenAPITools/openapi-generator-cli)
| [`2.9.0` ->
`2.13.4`](https://renovatebot.com/diffs/npm/@openapitools%2fopenapi-generator-cli/2.9.0/2.13.4)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@openapitools%2fopenapi-generator-cli/2.13.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@openapitools%2fopenapi-generator-cli/2.13.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@openapitools%2fopenapi-generator-cli/2.9.0/2.13.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@openapitools%2fopenapi-generator-cli/2.9.0/2.13.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>OpenAPITools/openapi-generator-cli
(@&#8203;openapitools/openapi-generator-cli)</summary>

###
[`v2.13.4`](https://togithub.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.4)

[Compare
Source](https://togithub.com/OpenAPITools/openapi-generator-cli/compare/v2.13.3...v2.13.4)

##### Bug Fixes

- **deps:** update dependency
[@&#8203;nestjs/axios](https://togithub.com/nestjs/axios) to v3.0.2
([#&#8203;765](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/765))
([37597a2](https://togithub.com/OpenAPITools/openapi-generator-cli/commit/37597a25e0959b970ced8c5d1ada70700f045d81))

###
[`v2.13.3`](https://togithub.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.3)

[Compare
Source](https://togithub.com/OpenAPITools/openapi-generator-cli/compare/v2.13.2...v2.13.3)

##### Bug Fixes

- **deps:** update dependency axios to v1.6.8
([#&#8203;766](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/766))
([5dff424](https://togithub.com/OpenAPITools/openapi-generator-cli/commit/5dff424aa15a2e23693d092bf42050a7df290601))

###
[`v2.13.2`](https://togithub.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.2)

[Compare
Source](https://togithub.com/OpenAPITools/openapi-generator-cli/compare/v2.13.1...v2.13.2)

##### Bug Fixes

- **app:** configure http with proxy url if present in environment
([#&#8203;762](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/762))
([7787f07](https://togithub.com/OpenAPITools/openapi-generator-cli/commit/7787f07edfe5a9d8d5272646bf54311a31c89e62)),
closes
[OpenAPITools/openapi-generator-cli#714](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/714)

###
[`v2.13.1`](https://togithub.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.1)

[Compare
Source](https://togithub.com/OpenAPITools/openapi-generator-cli/compare/v2.13.0...v2.13.1)

##### Reverts

- Revert "fix(deps): update dependency reflect-metadata to v0.2.1
([#&#8203;773](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/773))"
([#&#8203;777](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/777))
([fb01b0b](https://togithub.com/OpenAPITools/openapi-generator-cli/commit/fb01b0b6416a7a32da1c11fccda77f150e57df84)),
closes
[#&#8203;773](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/773)
[#&#8203;777](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/777)

###
[`v2.13.0`](https://togithub.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.0)

[Compare
Source](https://togithub.com/OpenAPITools/openapi-generator-cli/compare/v2.12.1...v2.13.0)

##### Features

-
**[#&#8203;644](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/644):**
add cli option for openapitools.json
([#&#8203;754](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/754))
([1d2a1a2](https://togithub.com/OpenAPITools/openapi-generator-cli/commit/1d2a1a2b40e0b509970f4b1c65190448237e4f1e)),
closes
[#&#8203;644](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/644)

###
[`v2.12.1`](https://togithub.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.12.1)

[Compare
Source](https://togithub.com/OpenAPITools/openapi-generator-cli/compare/v2.12.0...v2.12.1)

##### Bug Fixes

- **deps:** update dependency reflect-metadata to v0.2.1
([#&#8203;773](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/773))
([f6dcb95](https://togithub.com/OpenAPITools/openapi-generator-cli/commit/f6dcb9557cf1549e9b07da1b274d1d9a90ad5c70))

###
[`v2.12.0`](https://togithub.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.12.0)

[Compare
Source](https://togithub.com/OpenAPITools/openapi-generator-cli/compare/v2.11.0...v2.12.0)

##### Features

- **release:** trigger a release
([ad97182](https://togithub.com/OpenAPITools/openapi-generator-cli/commit/ad97182dac3fc2fec59c70fa96e7213d0a475dd3))

###
[`v2.11.0`](https://togithub.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.11.0)

[Compare
Source](https://togithub.com/OpenAPITools/openapi-generator-cli/compare/v2.10.1...v2.11.0)

##### Features

- **release:** trigger a release
([7e43a4e](https://togithub.com/OpenAPITools/openapi-generator-cli/commit/7e43a4e4f91148dede80fb7849eb473db759eb17))

###
[`v2.10.1`](https://togithub.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.10.1)

[Compare
Source](https://togithub.com/OpenAPITools/openapi-generator-cli/compare/v2.10.0...v2.10.1)

##### Reverts

- Revert "support JAVA_HOME environment variable
([#&#8203;756](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/756))"
([#&#8203;761](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/761))
([2a9aef9](https://togithub.com/OpenAPITools/openapi-generator-cli/commit/2a9aef9ca4bd1a197bdf414e0ba24b1c4d7d6a28)),
closes
[#&#8203;756](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/756)
[#&#8203;761](https://togithub.com/OpenAPITools/openapi-generator-cli/issues/761)

###
[`v2.10.0`](https://togithub.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.10.0)

[Compare
Source](https://togithub.com/OpenAPITools/openapi-generator-cli/compare/v2.9.0...v2.10.0)

##### Features

- **release:** trigger a release
([5d0e7c0](https://togithub.com/OpenAPITools/openapi-generator-cli/commit/5d0e7c0fc1076ba783424c89bf61c9bff6f112ed))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week
of the year before 4am on Monday" (UTC), Automerge - At any time (no
schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/bitwarden/sdk).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNTEuMiIsInVwZGF0ZWRJblZlciI6IjM3LjM1MS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment