Skip to content

Commit

Permalink
fix: invalid_input API errors may not return details (#507)
Browse files Browse the repository at this point in the history
The create uploaded certificate endpoint may return the following error:

```
{
  "error": {
    "code": "invalid_input",
    "message": "certificate must use larger key size"
  }
}
```

This change ensure that we do not get a json unmarshal error (unexpected
end of json) while trying to parse a non-existing details data.
  • Loading branch information
jooola committed Aug 9, 2024
1 parent 60c5428 commit ca78af2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hcloud/schema/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (e *Error) UnmarshalJSON(data []byte) (err error) {
if err = json.Unmarshal(data, alias); err != nil {
return
}
if e.Code == "invalid_input" {
if e.Code == "invalid_input" && len(e.DetailsRaw) > 0 {
details := ErrorDetailsInvalidInput{}
if err = json.Unmarshal(e.DetailsRaw, &details); err != nil {
return
Expand Down

0 comments on commit ca78af2

Please sign in to comment.