Skip to content

Commit

Permalink
Add length check for empty policy content (#326)
Browse files Browse the repository at this point in the history
If an empty file used as input for policy creation a zero sized
byte array gets passed. Corrected the check to see length and if
it's zero, error out. Earlier error was confusing as below
```
mc: <ERROR> Unable to create new policy. You must provide the Content-Length HTTP header.
```

Signed-off-by: Shubhendu Ram Tripathi <[email protected]>
  • Loading branch information
shtripat authored Jan 16, 2025
1 parent 5664504 commit dae7ce4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion policy-commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (adm *AdminClient) RemoveCannedPolicy(ctx context.Context, policyName strin

// AddCannedPolicy - adds a policy for a canned.
func (adm *AdminClient) AddCannedPolicy(ctx context.Context, policyName string, policy []byte) error {
if policy == nil {
if len(policy) == 0 {
return ErrInvalidArgument("policy input cannot be empty")
}

Expand Down

0 comments on commit dae7ce4

Please sign in to comment.