Skip to content

Commit faeb031

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
fix: don't try to deserialize as json when ResponseBodyInto is []byte
1 parent c52f33d commit faeb031

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

internal/requestconfig/requestconfig.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,15 +543,15 @@ func (cfg *RequestConfig) Execute() (err error) {
543543
return nil
544544
}
545545

546-
// If the response happens to be a byte array, deserialize the body as-is.
547546
switch dst := cfg.ResponseBodyInto.(type) {
547+
// If the response happens to be a byte array, deserialize the body as-is.
548548
case *[]byte:
549549
*dst = contents
550-
}
551-
552-
err = json.NewDecoder(bytes.NewReader(contents)).Decode(cfg.ResponseBodyInto)
553-
if err != nil {
554-
return fmt.Errorf("error parsing response json: %w", err)
550+
default:
551+
err = json.NewDecoder(bytes.NewReader(contents)).Decode(cfg.ResponseBodyInto)
552+
if err != nil {
553+
return fmt.Errorf("error parsing response json: %w", err)
554+
}
555555
}
556556

557557
return nil

0 commit comments

Comments
 (0)