getlago / lago-go-client

Lago Go Client
MIT License
21 stars 18 forks source link

[BUG]: Multiple errors in error_details can't be unmarshalled #174

Closed jerbob92 closed 4 months ago

jerbob92 commented 5 months ago

Describe the bug When calling an endpoint that can return multiple errors (for example the event batch endpoint), RESTY can't parse the error into the error struct.

The error is:

WARN RESTY Cannot unmarshal response body: json: cannot unmarshal object into Go struct field Error.error_details of type []string

The JSON response of the error:

{
  "status": 422,
  "error": "Unprocessable Entity",
  "code": "validation_errors",
  "error_details": {
    "0": {
      "transaction_id": [
        "value_already_exist"
      ]
    },
    "1": {
      "transaction_id": [
        "value_already_exist"
      ]
    },
    "2": {
      "transaction_id": [
        "value_already_exist"
      ]
    }
  }
}

To Reproduce Call the event batch endpoint with multiple events that already exist.

Expected behavior Receiving an error struct that contains all the errors in the response.