Skip to content

Document that S3Core copies of a delete-marker source version raise OSError(EINVAL) #1346

Open

Description

@laughingman7743

Follow-up of #1338 (part of #1327).

Summary

The S3Core docstring (s3_core.py:499-503) and docs/filesystem.md (:400-401) say that an operation raises FileNotFoundError for a missing object or version that it reads. S3Core.copy_object() and S3Core.upload_part_copy() with a source version that is a delete marker raise OSError(errno.EINVAL) instead.

Measured S3 behavior

Probed on a temporary versioned bucket (us-east-1) at 1a6a0d6:

Request naming a delete-marker version Response
HeadObject, GetObject, GetObjectTagging, PutObjectTagging, GetObjectAcl, GetObjectAttributes 405 with x-amz-delete-marker: true → FileNotFoundError since #1338
CopyObject, UploadPartCopy (as the copy source) 400 InvalidRequest, no x-amz-delete-marker header, message "The source of a copy request may not specifically refer to a delete marker by version id." → OSError(EINVAL)

A permanently removed (well-formed) version ID gives 404 NoSuchVersion → FileNotFoundError for HeadObject, GetObject, CopyObject and GetObjectTagging. A malformed version ID gives 400 InvalidArgument → OSError(EINVAL).

The filesystem is not affected: cp_file, copy and mv (sync and aio) look up the source with info() first, which raises FileNotFoundError.

Fix direction

Document the exception instead of translating it: the 400 response carries neither a header nor an error code specific to delete markers, so only its message distinguishes it. State in the S3Core docstring, the copy_object()/upload_part_copy() docstrings, and docs/filesystem.md that a copy source naming a delete-marker version raises OSError (EINVAL), and that the filesystem's copies raise FileNotFoundError because they look up the source first.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions