databricks / cli

Databricks CLI
Other
148 stars 56 forks source link

[ISSUE] unexpected error handling request: json: cannot unmarshal number into Go struct field APIErrorBody.error_code of type string #1608

Closed michal-mmm closed 4 months ago

michal-mmm commented 4 months ago

Description I've got this error when running databricks bundle deploy on CI using Service Principal. It uses env variables for authentication (DATABRICKS_TOKEN, HOST).

Error: unexpected error handling request: json: cannot unmarshal number into Go struct field APIErrorBody.error_code of type string. This is likely a bug in the Databricks SDK for Go or the underlying REST API. Please report this issue with the following debugging information to the SDK issue tracker at https://github.com/databricks/databricks-sdk-go/issues. Request log:

GET /api/2.0/preview/scim/v2/Me
> * Host: 
> * Accept: application/json
> * Authorization: REDACTED
> * Traceparent: xxx
> * User-Agent: cli/0.223.2 databricks-sdk-go/0.43.0 go/1.22.5 os/linux cmd/bundle_deploy auth/pat cicd/gitlab
< HTTP/2.0 403 Forbidden
< * Content-Length: 52
< * Content-Type: application/json; charset=utf-8
< * Date: Thu, 18 Jul 2024 13:18:52 GMT
< * Server: databricks
< * Vary: Accept-Encoding
< * X-Databricks-Reason-Phrase: Invalid access token.
< {
<   "error_code": 403,
<   "message": "Invalid access token."
< }

Expected behavior No error when deploying bundle in CI.

Additional context I tried downgrading databricks-cli but it didn't work. I downgraded to: cli/0.221.1 databricks-sdk-go/0.42.0 go/1.21.10 os/linux cmd/bundle_validate auth/pat cicd/gitlab

I had the same error still.

I guess this is a commit containing the fix. (I think, not a go programmer) https://github.com/databricks/databricks-sdk-go/commit/b58dc70d1f15435d2f881628c773a68ae38f1657

Releasing new CLI version with updated dependecy (which is already done via dependabot https://github.com/databricks/cli/commit/10fe02075fec0b2e18d2eacf7412816d6e81d6bc) would probably fix my issue.

pietern commented 4 months ago

Thanks for reporting!

You're right, the linked PR includes a fix for this issue. It is included in the most recent CLI release, v0.224.0.

pietern commented 4 months ago

This won't solve the issue that the token is invalid, of course, only the elaborate error message.