Error ERR_BAD_REQUEST 400 on hs project upload

Hi everyone, I’m very new on HubSpot API and integrations, just get my hand on it literally last week. I am in need of someone helping me on one specific error when doing command hs project upload.

In summary, the command works fine on my local laptop - both org and personal - but not on our org designated GitHub enterprise runner. And of course - as other org would do too - is sitting behind enterprise security tools (firewall, proxy, VPN, etc. you name it).

[DEBUG] Attempting to track usage of "project-upload" command[DEBUG] Sending usage event to authenticated endpoint[DEBUG] HubSpotHttpError:- message: The request was bad.- status: 400- statusText: Bad Request- method: get- code: ERR_BAD_REQUEST- derivedContext: {"accountId": ***,"request": "developer/projects/v1/by-name/sample-private-app"}

The thing is, although --debug is provided, we do not know which endpoint is hitting (like the full URL). So that with this information, we can ask our org SecOps team to discuss, allowlist, etc. We’re running blind now.

I’m currently swimming (and possibly drowning) in both HubSpot CLI source code (GitHub - HubSpot/hubspot-cli) and HubSpot Local Dev Lib (GitHub - HubSpot/hubspot-local-dev-lib) hoping to find something there, since the support doesn’t provide assistance on this.

So my humble question to all the HubSpot shifu here:

  • Any idea how to find the needle in this pile of code? Any out-of-the-box idea you can suggest?
  • How do we get the full endpoint URL straightaway from this error?

Hey, @RadityoArdi :waving_hand: Welcome to our community! I’d like to invite some of our community members to the conversation — hey @Teun @Kevin-C @nikodev have you run into this before?

Thanks for taking a look! — Jaycee

thanks. I spent almost a day or two, looking out for this issue. I thought almost closing to the core issue by tracing the code, and found the full URL of the problematic endpoint https://api.hubapi.com/developer/projects/v1/by-name/sample-private-app with GET.

Inside the code, if I understand correctly, this endpoint call is used to check whether the project exists in the HubSpot account, which clearly indeed is not since this is the first time deployment. You can take a look at https://github.com/HubSpot/hubspot-cli/blob/main/lib/projects.ts line 239 inside ensureProjectExists, it’s clearly fails at fetchProject function, which is valid as the project is not there in the account.

Let’s get into serious detail, shall we?

  • sample-private-app → is a private app that was created via HubSpot CLI, but has never been deployed.
  • rd-private-app → is a private app that was created and successfully deployed before via HubSpot CLI (hs project upload), with personal laptop.

I then tried to construct the endpoint and call Invoke-WebRequest - a PowerShell function - and provide the private access key of the HubSpot account in “Authorization” header. And compare witih the already existing projects. All this, while executing in personal laptop to see the HTTP Response difference.

The endpoint https://api.hubapi.com/developer/projects/v1/by-name/sample-private-app returns 404 Not Found, as expected. Hence, based on the logic it will ask whether --forceCreate is provided. If not, it’ll then create on the fly and then deploy.

The other endpoint https://api.hubapi.com/developer/projects/v1/by-name/rd-private-app returns 200 OK, as expected either.

We then, use these 2 scripts (literally only 2 lines) to our org GitHub runner, to see whether it will behave the same for sample-private-app to return 400 Bad Request, or 404 Not Found.

To my surprise, both URLs behaves exactly the same in org GitHub runner just like in my personal laptop. sample-private-app returns 404 Not Found, while rd-private-app returns 200 OK.

So, I’m totally lost right now. It could still be related to Network issue, a previous HTTP call that didn’t construct the data properly until 400 Bad Request came up in the CLI. Or maybe something else related to authentication, or even probably the construction of the zip file in the first place, I don’t know.

My next move would be to inject some code with more logs, build it, then run it inside GitHub runner. But aside from this, can you guys help me to pinpoint, or to walkthrough what could be the sequence of the HTTP request before that specific endpoint being called?

Hi, bumping up this post. Anyone has any idea?