Skip to content

[ISSUE] Databricks Go SDK fails to decode an API error response when the backend returns a numeric error_code instead of a string. #1317

@Oliveryoekk

Description

@Oliveryoekk

Error message
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.

GET /api/2.0/preview/scim/v2/Me
> * Host: 
> * Accept: application/json
> * Authorization: REDACTED
> * User-Agent: cli/0.215.0 databricks-sdk-go/0.34.0 go/1.21.7 os/linux cmd/bundle_deploy auth/pat cicd/azure-devops
< HTTP/2.0 403 Forbidden
< * Alt-Svc: clear
< * Content-Length: 98
< * Content-Type: application/json; charset=utf-8
< * Date: Mon, 03 Nov 2025 23:00:30 GMT
< * Server: databricks
< * Server-Timing: request_id;dur=0;desc="5c35ebdd-aa15-4225-92ed-66c31d467cf6", client_protocol;dur=0;desc="HTTP/2"
< * Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
< * Vary: Accept-Encoding
< * X-Content-Type-Options: nosniff
< * X-Databricks-Org-Id: 
< * X-Databricks-Reason-Phrase: Invalid access token.
< * X-Request-Id: 5c35ebdd-aa15-4225-92ed-66c31d467cf6
< {
<   "error_code": 403,
<   "message": "Invalid access token. [ReqId: 5c35ebdd-aa15-4225-92ed-66c31d467cf6]"
< }

The SDK should handle both string and numeric error_code values gracefully, or the Databricks API should always return error_code as a string.

Actual behavior

When the REST API returns a numeric error_code, JSON unmarshalling fails before the error can be propagated to the caller. This occurs inside the SDK’s error handling logic (APIErrorBody.error_code defined as string).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions