box / boxcli

A command line interface for interacting with the Box API.
https://developer.box.com
Apache License 2.0
228 stars 59 forks source link

Using Proxy causes ”Agent is not a constructor” error #505

Closed kobay closed 1 year ago

kobay commented 1 year ago

I have checked that the SDK documentation doesn't solve my issue.

I have checked that the API documentation doesn't solve my issue.

I have checked that the Box Developer Forums doesn't solve my issue.

I have searched Issues in this repo and my issue isn't already reported.

Describe the bug

After box cli v3.9.1, using proxy causes ”Agent is not a constructor” error. I guess proxy-agent v6.3.0 in box-node-sdk v3.1.1, which is upgraded at cli v3.9.1, is some how related to this error. The latest version v3.12.0 has the same problem.

Expected behavior

box cli works with proxy

Steps to reproduce

➜  ~ box -v
@box/cli/3.9.1 darwin-arm64 node-v20.8.1
➜  ~ box configure:settings --proxy-url=socks://localhost:8889 --enable-proxy
{
    "boxReportsFolderPath": "/Users/hkobayashi/Documents/Box-Reports",
    "boxReportsFileFormat": "txt",
    "boxDownloadsFolderPath": "/Users/hkobayashi/Downloads/Box-Downloads",
    "outputJson": true,
    "enableProxy": true,
    "proxy": {
        "url": "socks://localhost:8889",
        "username": null,
        "password": null
    },
    "enableAnalyticsClient": false,
    "analyticsClient": {
        "name": "test-2023-08-30-analytics-client"
    }
}
➜  ~ box users:get
Agent is not a constructor

Authentication method used in your application

Server Authentication (with JWT)

App Access Level

App + Enterprise Access

What is Box CLI Version and Node used?

@box/cli/3.9.1 darwin-arm64 node-v20.8.1

What is your Operating System Version?

Mac Ventura 13.6

mwwoda commented 1 year ago

Thanks for reporting the issue. It looks like there is indeed a problem with the proxy in the current version of the CLI. I have created a ticket internally and I'll followup here in case of any updates.

congminh1254 commented 1 year ago

Hi @kobay We have just fixed the issue with the proxy and will release the new version next week. Best, Minh

congminh1254 commented 1 year ago

Hi @kobay

We have just released the version 3.12.1 of BoxCLI, and the proxy should working now.

Best, Minh

kobay commented 1 year ago

Hi @congminh1254 I tested v3.12.1 but I still get another error if I turn on the proxy.

➜  ~ box -v
@box/cli/3.12.1 darwin-arm64 node-v20.9.0
➜  ~ box users:get
getaddrinfo ENOTFOUND localhost:8889
congminh1254 commented 1 year ago

Hi @kobay Let me check and I will get back to you asap.

congminh1254 commented 1 year ago

Hi @kobay

Please check again with the latest vesion.

Thankyou

kobay commented 1 year ago

Hi @congminh1254 Thank you! I confirmed v3.12.2 works properly with a proxy.