mirror of
https://github.com/pgsty/minio.git
synced 2026-08-08 23:33:30 +03:00
Add more context aware error for policy parsing errors (#8726)
In existing functionality we simply return a generic error such as "MalformedPolicy" which indicates just a generic string "invalid resource" which is not very meaningful when there might be multiple types of errors during policy parsing. This PR ensures that we send these errors back to client to indicate the actual error, brings in two concrete types such as - iampolicy.Error - policy.Error Refer #8202
This commit is contained in:
@@ -18,7 +18,6 @@ package policy
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/minio/minio-go/v6/pkg/set"
|
||||
"github.com/minio/minio/pkg/wildcard"
|
||||
@@ -42,7 +41,7 @@ func (p Principal) Intersection(principal Principal) set.StringSet {
|
||||
// MarshalJSON - encodes Principal to JSON data.
|
||||
func (p Principal) MarshalJSON() ([]byte, error) {
|
||||
if !p.IsValid() {
|
||||
return nil, fmt.Errorf("invalid principal %v", p)
|
||||
return nil, Errorf("invalid principal %v", p)
|
||||
}
|
||||
|
||||
// subtype to avoid recursive call to MarshalJSON()
|
||||
@@ -75,7 +74,7 @@ func (p *Principal) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
if s != "*" {
|
||||
return fmt.Errorf("invalid principal '%v'", s)
|
||||
return Errorf("invalid principal '%v'", s)
|
||||
}
|
||||
|
||||
sp.AWS = set.CreateStringSet("*")
|
||||
|
||||
Reference in New Issue
Block a user