Skip to content

Commit

Permalink
api: return parse errors if any for storage endpoints (#12338)
Browse files Browse the repository at this point in the history
* logical/list: return parseErr if any

* changelog

* Add parseErr to other API endpoints

* Update 12338.txt
  • Loading branch information
jasonodonnell authored Aug 17, 2021
1 parent fa91a68 commit 5e505ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 5 additions & 5 deletions api/logical.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (c *Logical) ReadWithData(path string, data map[string][]string) (*Secret,
case io.EOF:
return nil, nil
default:
return nil, err
return nil, parseErr
}
if secret != nil && (len(secret.Warnings) > 0 || len(secret.Data) > 0) {
return secret, nil
Expand Down Expand Up @@ -115,7 +115,7 @@ func (c *Logical) List(path string) (*Secret, error) {
case io.EOF:
return nil, nil
default:
return nil, err
return nil, parseErr
}
if secret != nil && (len(secret.Warnings) > 0 || len(secret.Data) > 0) {
return secret, nil
Expand Down Expand Up @@ -159,7 +159,7 @@ func (c *Logical) write(path string, request *Request) (*Secret, error) {
case io.EOF:
return nil, nil
default:
return nil, err
return nil, parseErr
}
if secret != nil && (len(secret.Warnings) > 0 || len(secret.Data) > 0) {
return secret, err
Expand Down Expand Up @@ -206,7 +206,7 @@ func (c *Logical) DeleteWithData(path string, data map[string][]string) (*Secret
case io.EOF:
return nil, nil
default:
return nil, err
return nil, parseErr
}
if secret != nil && (len(secret.Warnings) > 0 || len(secret.Data) > 0) {
return secret, err
Expand Down Expand Up @@ -259,7 +259,7 @@ func (c *Logical) Unwrap(wrappingToken string) (*Secret, error) {
case io.EOF:
return nil, nil
default:
return nil, err
return nil, parseErr
}
if secret != nil && (len(secret.Warnings) > 0 || len(secret.Data) > 0) {
return secret, nil
Expand Down
3 changes: 3 additions & 0 deletions changelog/12338.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note: bug
api: Fixes storage APIs returning incorrect error when parsing responses
```

0 comments on commit 5e505ec

Please sign in to comment.