iam: return service failure when listing inline policies fails

A ListUserInlinePolicies error in GetUserPolicy fell through to
action-based reconstruction, masking a store failure as a policy
document. Propagate it as ServiceFailureException instead, matching
the standalone iam server and the other callers in this file.
This commit is contained in:
chrislusf committed 2026-10-21 23:05:28 -07:00
1 parent 42cb8b91f4
commit aac486d6e5
1 file changed
+5 -1
+5 -1
View File
@@ -1303,7 +1303,11 @@ func (e *EmbeddedIamApi) GetUserPolicy(s3cfg *iam_pb.S3ApiConfiguration, values
}
// The user has stored inline policies, but none by this name
if storeErr == nil {
if names, err := e.credentialManager.ListUserInlinePolicies(ctx, userName); err == nil && len(names) > 0 {
policyNames, err := e.credentialManager.ListUserInlinePolicies(ctx, userName)
if err != nil {
return resp, &iamError{Code: iam.ErrCodeServiceFailureException, Error: fmt.Errorf("list inline policies for %s: %w", userName, err)}
}
if len(policyNames) > 0 {
return resp, &iamError{Code: iam.ErrCodeNoSuchEntityException, Error: fmt.Errorf("the user policy with name %s cannot be found", policyName)}
}
}