Closed avinashpodisetti closed 3 months ago
Hi @avinashpodisetti. Thank you for raising this issue and apologies for the late reply.
Hi @radu-stefan-dt . Thanks for getting back to me..
Can you manually hit the https://dt-managed-notprod.xxxxxxxx.com/e/e1fc94f/api/v1/time url in the browser? yes, i am able to hit the URL manually
Are you using a proxy to get to your Dynatrace tenant? Yes we have proxy in place. i have HTTP_PROXY, HTTPS_PROXY configured as Environment variables. so VScode use those variables to reach to Dynatrace managed tenant.
Could you share a few details about your setup? Attached my settings.JSON from VSCode and ENV ENV.txt settings.json
Are you able to access any logs on the proxy side about these requests?
From the extension all the configuration is applied correctly. Namely, I can see that the URL is recognized and SSL verification is disabled.
We don't have any handling of the HTTP_PROXY
, HTTPS_PROXY
environment variables as this was assumed to work with anything running in VSCode without additional processing.
I have a similar issue, the only difference is I'm getting a 405 instead of a 400 error:
2024-07-01T16:11:16.181Z [ERROR][utils.conditionCheckers.checkEnvironmentConnected] You must be connected to a Dynatrace Environment to use this command.
2024-07-01T16:11:35.473Z [ERROR][utils.conditionCheckers.checkUrlReachable] {"message":"Request failed with status code 405","name":"AxiosError","stack":"AxiosError: Request failed with status code 405\n at Ba (/home/xxxxxx/.vscode-server/extensions/dynatraceplatformextensions.dynatrace-extensions-2.6.1/out/main.js:185:1040)\n at IncomingMessage.<anonymous> (/home/xxxxxx/.vscode-server/extensions/dynatraceplatformextensions.dynatrace-extensions-2.6.1/out/main.js:186:8709)\n at IncomingMessage.emit (node:events:530:35)\n at endReadableNT (node:internal/streams/readable:1696:12)\n at processTicksAndRejections (node:internal/process/task_queues:82:21)","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"adapter":["xhr","http"],"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"application/json, text/plain, */*","User-Agent":"axios/1.6.3","Accept-Encoding":"gzip, compress, deflate, br"},"maxRedirects":20,"method":"get","url":"https://xxxxxxxxx.live.dynatrace.com/api/v1/time"},"code":"ERR_BAD_REQUEST","status":405}
I'm also using a proxy configured in settings.json
as
{
"http.proxy": "http://localhost:8888",
"http.proxyAuthorization": null
}
to reach the internet. Other VSC extensions which communicate with the internet work fine in the same workspace (e.g. GitHub Copilot).
After I get the error I can see the following entries in the proxy log e.g.:
{"level":"debug","ts":1719851877.3312619,"msg":"Request started","http_proto":"HTTP/1.1","http_method":"GET","user_agent":"axios/1.6.3","uri":"https://xxxxxxxxx.live.dynatrace.com/api/v1/time"}
{"level":"debug","ts":1719851877.3312619,"msg":"Request completed","http_proto":"HTTP/1.1","http_method":"GET","user_agent":"axios/1.6.3","uri":"https://xxxxxxxxx.live.dynatrace.com/api/v1/time"}
I can reach the same URL https://xxxxxxxxx.live.dynatrace.com/api/v1/time
in a VSC terminal window via curl just fine when going through the same proxy e.g.
$ env | grep -i _proxy
https_proxy=http://localhost:8888
HTTPS_PROXY=http://localhost:8888
HTTP_PROXY=http://localhost:8888
http_proxy=http://localhost:8888
$ curl https://xxxxxxxxx.live.dynatrace.com/api/v1/time
1719852903595
but then I get additional/different log entries:
{"level":"debug","ts":1719852264.9799116,"msg":"Request started","http_proto":"HTTP/1.1","http_method":"CONNECT","user_agent":"curl/7.81.0","uri":"xxxxxxxxx.live.dynatrace.com:443"}
{"level":"debug","ts":1719852265.115475,"msg":"CONNECT tunnel opened","http_proto":"HTTP/1.1","http_method":"CONNECT","user_agent":"curl/7.81.0","uri":"xxxxxxxxx.live.dynatrace.com:443"}
{"level":"debug","ts":1719852265.35032,"msg":"Traffic copied successfully","http_proto":"HTTP/1.1","http_method":"CONNECT","user_agent":"curl/7.81.0","uri":"xxxxxxxxx.live.dynatrace.com:443"}
{"level":"debug","ts":1719852265.352512,"msg":"CONNECT tunnel closed","http_proto":"HTTP/1.1","http_method":"CONNECT","user_agent":"curl/7.81.0","uri":"xxxxxxxxx.live.dynatrace.com:443"}
{"level":"debug","ts":1719852265.3564875,"msg":"Request completed","http_proto":"HTTP/1.1","http_method":"CONNECT","user_agent":"curl/7.81.0","uri":"xxxxxxxxx.live.dynatrace.com:443"}
It looks like the extension is talking to the proxy as if it would be the destination host instead of establishing a tunnel via the CONNECT
method...
Hi @d41k4n
What you're describing makes sense. The extension creates an Axios client, and then uses it to make requests to the URLs as needed (in your case GET
to https://<tenant>/api/v1/time
). The VSCode settings for proxies are not processed and added to this client at all, as that was assumed to be handled by VSCode for all extensions.
Judging by the details you shared as well as @avinashpodisetti above, I'm not sure the assumption that VSCode will handle proxy communications on behalf of extensions stands true. This might have to become a feature request for us to process and pass on those settings into the Axios client.
Hi @radu-stefan-dt
The VSCode settings for proxies are not processed and added to this client at all, as that was assumed to be handled by VSCode for all extensions.
If this is true then why is the extension even trying to contact the proxy host (which in my case is configured in the VSCode settings) via GET method?
So if I understood correctly the extension is currently lacking all proxy support, correct?
why is the extension even trying to contact the proxy host
I have a feeling Axios might also recognize those environment variables and apply them automatically.
I'm not sure if there is any difference compared to when proxy details are explicitly fed into the Axios client setup.
the extension is currently lacking all proxy support, correct?
Any support is untested and involuntary due to the standard environment variables.
@d41k4n could you please remove the port from the proxy variable?
Instead of:
HTTPS_PROXY=http://localhost:8888
HTTP_PROXY=http://localhost:8888
Use:
HTTPS_PROXY=http://localhost
HTTP_PROXY=http://localhost
@radu-stefan-dt
Doesn't help - the only difference is now I'm getting a 400 instead of a 405:
2024-07-05T10:57:27.386Z [ERROR][utils.conditionCheckers.checkUrlReachable] {"message":"Request failed with status code 400","name":"AxiosError","stack":"AxiosError: Request failed with status code 400\n at Ba (/home/xxxxxx/.vscode-server/extensions/dynatraceplatformextensions.dynatrace-extensions-2.6.1/out/main.js:185:1040)\n at IncomingMessage.<anonymous> (/home/xxxxxx/.vscode-server/extensions/dynatraceplatformextensions.dynatrace-extensions-2.6.1/out/main.js:186:8709)\n at IncomingMessage.emit (node:events:530:35)\n at endReadableNT (node:internal/streams/readable:1696:12)\n at processTicksAndRejections (node:internal/process/task_queues:82:21)","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"adapter":["xhr","http"],"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"application/json, text/plain, */*","User-Agent":"axios/1.6.3","Accept-Encoding":"gzip, compress, deflate, br"},"maxRedirects":20,"method":"get","url":"https://xxxxxxxx.live.dynatrace.com/api/v1/time"},"code":"ERR_BAD_REQUEST","status":400}
Btw, this is how I configured the proxy in VSCode:
FYI: The env vars "https_proxy" and "http_proxy" are not set anywhere else on the system or in VSCode.
With how things are currently implemented, there is little help I can offer.
I am transferring this into a feature idea under #244
Description
Getting following error while connecting to a managed tenant from VSCode.
Workspace setup: Running VS Code on MAC
extension settings:
Error Message support_archive_mac.zip
{"message":"Request failed with status code 400","name":"AxiosError","stack":"AxiosError: Request failed with status code 400\n at Ba (/Users/lidsc82/.vscode/extensions/dynatraceplatformextensions.dynatrace-extensions-2.6.1-darwin-x64/out/main.js:185:1040)\n at IncomingMessage. (/Users/lidsc82/.vscode/extensions/dynatraceplatformextensions.dynatrace-extensions-2.6.1-darwin-x64/out/main.js:186:8709)\n at IncomingMessage.emit (node:events:529:35)\n at endReadableNT (node:internal/streams/readable:1368:12)\n at processTicksAndRejections (node:internal/process/task_queues:82:21)","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"adapter":["xhr","http"],"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"application/json, text/plain, /","User-Agent":"axios/1.6.3","Accept-Encoding":"gzip, compress, deflate, br"},"maxRedirects":20,"method":"get","url":"https://dt-managed-notprod.xxxxxxxx.com/e/e1fc94f/api/v1/time"},"code":"ERR_BAD_REQUEST","status":400}
Steps to reproduce
initialized workspace and trying to add environment
Support information