From 5e86a34e3e0f54a2076850df7297d45b43c292e1 Mon Sep 17 00:00:00 2001 From: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com> Date: Tue, 17 Aug 2021 13:19:39 -0400 Subject: [PATCH] api: return parse errors if any for storage endpoints (#12338) * logical/list: return parseErr if any * changelog * Add parseErr to other API endpoints * Update 12338.txt --- api/logical.go | 10 +++++----- changelog/12338.txt | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 changelog/12338.txt diff --git a/api/logical.go b/api/logical.go index 977a41ae3..cd950a2b7 100644 --- a/api/logical.go +++ b/api/logical.go @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/changelog/12338.txt b/changelog/12338.txt new file mode 100644 index 000000000..6faf03eb5 --- /dev/null +++ b/changelog/12338.txt @@ -0,0 +1,3 @@ +```release-note: bug +api: Fixes storage APIs returning incorrect error when parsing responses +```