feat(s3s): implement access point and S3 on Outposts ARN support in CopySource#527
Merged
feat(s3s): implement access point and S3 on Outposts ARN support in CopySource#527
Conversation
- Add `Outpost` variant to `CopySource` enum with `partition`, `region`, `account_id`, `outpost_id`, `key`, and `version_id` fields - Add `partition` field to `AccessPoint` variant for full roundtrip fidelity across all AWS partitions (aws, aws-cn, aws-us-gov) - Add `check_access_point_name()`: validates 3-63 chars, lowercase alphanumeric + hyphens, no consecutive hyphens, no leading/trailing hyphens - Add `check_account_id()`: validates exactly 12 ASCII digits - Add `ParseCopySourceError::InvalidArn`, `::InvalidAccessPointName`, `::InvalidAccountId` error variants - Implement `format_to_string()` for `AccessPoint` and `Outpost` using stored partition for correct ARN reconstruction - Expand test suite from 31 to 48 tests covering parse, format, roundtrip, and validation edge cases for all three CopySource formats Co-authored-by: GitHub Copilot <copilot@github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for parsing and formatting ARN-based x-amz-copy-source values (Access Point and S3 on Outposts) in the s3s DTO layer, enabling CopyObject/UploadPartCopy callers to accept these AWS-defined header formats.
Changes:
- Extended
CopySourceto represent Access Point ARNs (with partition + versionId) and added a new Outpost ARN variant. - Implemented ARN parsing/validation (partition/service/region/account-id, access point name checks) and formatting for the new variants.
- Updated
s3s-fsto explicitly reject Outpost copy sources withNotImplemented(matching existing AccessPoint behavior).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/s3s/src/dto/copy_source.rs | Adds new CopySource variants, ARN parsing/validation helpers, formatting, and expanded unit tests. |
| crates/s3s-fs/src/s3.rs | Treats CopySource::Outpost as NotImplemented in filesystem backend copy paths. |
- Add encode_path() helper that URL-encodes path segments while preserving / separators - Update format_to_string() for all three variants (Bucket, AccessPoint, Outpost) to use encode_path(key) and urlencoding::encode(version_id) - Add error branch tests covering InvalidBucketName, InvalidKey (bucket and outpost), InvalidEncoding (version_id), and InvalidArn (outpost bad resource prefix) - Add encoded roundtrip tests verifying parse -> format_to_string preserves URL-encoded keys with spaces and special characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements full parsing and formatting support for the two ARN-based
x-amz-copy-sourceformats defined in the AWS S3 CopyObject API, resolving the// FIXME: support access pointcomment incopy_source.rs.AWS Format Reference
The
x-amz-copy-sourceheader supports three formats:<bucket>/<key>[?versionId=<id>]arn:<partition>:s3:<region>:<account-id>:accesspoint/<name>/object/<key>[?versionId=<id>]arn:<partition>:s3-outposts:<region>:<account-id>:outpost/<outpost-id>/object/<key>[?versionId=<id>]Supported partitions:
aws,aws-cn,aws-us-gov.Changes
crates/s3s/src/dto/copy_source.rsEnum changes:
AccessPointvariant: addpartitionfield andversion_idfieldOutpostvariant:partition,region,account_id,outpost_id,key,version_idNew error variants:
InvalidArn— malformed ARN structure or unsupported service/partitionInvalidAccessPointName— name fails AWS naming rulesInvalidAccountId— account ID is not exactly 12 ASCII digitsNew validation functions:
check_access_point_name(name)— 3–63 chars, lowercase alphanumeric + hyphens, no leading/trailing hyphens, no consecutive hyphenscheck_account_id(id)— exactly 12 ASCII digitsParsing (
parse()):extract_version_id()helperarn:prefix and dispatches toparse_arn()parse_arn()usessplitn(6, ':')to preserve colons in the resource segmentpartitionis propagated through the call chain and stored in the variantFormatting (
format_to_string()):AccessPointandOutpostusing the storedpartitionfieldcrates/s3s-fs/src/s3.rsmatch CopySourcesites: addedCopySource::Outpost { .. }arm returningNotImplementedTest Coverage
Tests expanded from 31 → 48, all passing.
/object/delimiter, empty resource components, invalid encodingQuality