Skip to content

Commit ca78af2

Browse files
authored
fix: invalid_input API errors may not return details (#507)
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.
1 parent 60c5428 commit ca78af2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

hcloud/schema/error.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func (e *Error) UnmarshalJSON(data []byte) (err error) {
1717
if err = json.Unmarshal(data, alias); err != nil {
1818
return
1919
}
20-
if e.Code == "invalid_input" {
20+
if e.Code == "invalid_input" && len(e.DetailsRaw) > 0 {
2121
details := ErrorDetailsInvalidInput{}
2222
if err = json.Unmarshal(e.DetailsRaw, &details); err != nil {
2323
return

0 commit comments

Comments
 (0)