Skip to content

Commit

Permalink
layer: Return unsupported error if meta parameter is empty
Browse files Browse the repository at this point in the history
Closes #846.

Signed-off-by: Evgenii Baidakov <[email protected]>
  • Loading branch information
smallhive committed Oct 13, 2023
1 parent b457e6b commit dd2343a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ This document outlines major changes between releases.

## [Unreleased]

### Added
- Passing an empty meta parameter value raises "Your metadata headers are not supported." error.

## [0.29.0] - 2023-09-28

### Added
Expand Down
4 changes: 4 additions & 0 deletions api/handler/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func transformToS3Error(err error) error {
return s3errors.GetAPIError(s3errors.ErrAccessDenied)
}

if errorsStd.Is(err, layer.ErrMetaEmptyParameterValue) {
return s3errors.GetAPIError(s3errors.ErrUnsupportedMetadata)
}

return s3errors.GetAPIError(s3errors.ErrInternalError)
}

Expand Down
3 changes: 3 additions & 0 deletions api/layer/neofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ type PrmObjectDelete struct {
// ErrAccessDenied is returned from NeoFS in case of access violation.
var ErrAccessDenied = errors.New("access denied")

// ErrMetaEmptyParameterValue describes situation when meta parameter was passed but with empty value.
var ErrMetaEmptyParameterValue = errors.New("meta empty parameter value")

// NeoFS represents virtual connection to NeoFS network.
type NeoFS interface {
// CreateContainer creates and saves parameterized container in NeoFS.
Expand Down
6 changes: 6 additions & 0 deletions api/layer/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ func ParseCompletedPartHeader(hdr string) (*Part, error) {
}

// PutObject stores object into NeoFS, took payload from io.Reader.
//
// Returns [ErrMetaEmptyParameterValue] error if any attribute parameter is empty.
func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.ExtendedObjectInfo, error) {
owner := n.Owner(ctx)

Expand Down Expand Up @@ -240,6 +242,10 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Extend
prm.Attributes = make([][2]string, 0, len(p.Header))

for k, v := range p.Header {
if v == "" {
return nil, ErrMetaEmptyParameterValue
}

prm.Attributes = append(prm.Attributes, [2]string{k, v})
}

Expand Down
6 changes: 6 additions & 0 deletions docs/aws_s3_compat.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,9 @@ See also `GetObject` and other method parameters.
| 🔵 | DeleteBucketWebsite | |
| 🔵 | GetBucketWebsite | |
| 🔵 | PutBucketWebsite | |


## Metadata

Each meta parameter value must be non-empty. If any parameter value is an empty,
then "Your metadata headers are not supported." error will be returned on the object put operation.

0 comments on commit dd2343a

Please sign in to comment.