Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Implements success_action_status and success_action_redirect form fields for S3 POST object uploads per AWS S3 REST API spec.

Changes

Code Generation:

  • Updated codegen/src/v1/ops.rs to generate code for extracting and validating success_action_status and success_action_redirect from multipart forms
  • Generates validation logic (only accepts 200, 201, 204 for status)
  • Generates code to call helper functions for response handling

New Modules:

  • crates/s3s/src/ops/post_object.rs: Helper functions for success_action handling
    • handle_success_action_redirect: Returns 303 with Location header + query params
    • handle_success_action_status: Returns specified status with optional XML body
  • crates/s3s/src/dto/post_response.rs: PostResponse DTO with XML serialization

Request handling:

  • Added success_action_status and success_action_redirect fields to S3Extensions
  • Extract and validate fields during multipart form deserialization
    • success_action_status: Only accepts 200, 201, or 204
    • success_action_redirect: Stored as-is for response handling

Response modification in PutObject:

  • success_action_redirect takes precedence: returns 303 with Location header containing redirect URL + query params (bucket, key, etag)
  • success_action_status:
    • 200/201: XML PostResponse body with Location, Bucket, Key, ETag (using proper XML serialization)
    • 204: Empty body
    • Default (no field): Standard PutObject response unchanged

Security:

  • URL encoding for redirect query parameters via urlencoding crate
  • XML escaping via quick-xml serialization infrastructure

Applied to both standard and MinIO variants via code generation.

Related

rustfs/rustfs#1073

Original prompt

This section details on the original issue you should resolve

<issue_title>Missing support for success_action_status and success_action_redirect in S3 POST uploads</issue_title>
<issue_description>https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html

Related:

<agent_instructions>Try to fix this issue. Run CI checks before committing changes.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix missing support for success_action_status and success_action_redirect in S3 uploads Add support for success_action_status and success_action_redirect in POST object uploads Dec 10, 2025
Copilot AI requested a review from Nugine December 10, 2025 04:44
@Nugine
Copy link
Collaborator

Nugine commented Dec 14, 2025

@copilot

  1. Update the codegen to change generated files. Do not modify them directly.
  2. Try to build response by XML serialization. Do not build manually.
  3. Run CI format and checks.

- Reverted direct modifications to generated files
- Updated codegen to extract success_action_status and success_action_redirect
- Created post_object module with helper functions for response handling
- Created PostResponse DTO with XML serialization
- Used proper XML serialization instead of manual string building
- All tests pass, clippy clean

Co-authored-by: Nugine <[email protected]>
Copy link
Contributor Author

Copilot AI commented Dec 14, 2025

@copilot

  1. Update the codegen to change generated files. Do not modify them directly.
  2. Try to build response by XML serialization. Do not build manually.
    ...

Refactored as requested in commit f227416:

  1. ✅ Updated codegen instead of modifying generated files directly
  2. ✅ Used XML serialization infrastructure (created PostResponse DTO with proper Serialize impl)
  3. ✅ All CI checks pass (fmt, clippy, tests)

The implementation now:

  • Generates success_action handling code via codegen/src/v1/ops.rs
  • Uses PostResponse DTO with proper XML serialization (no manual string building)
  • Keeps response handling logic in post_object.rs module (similar to get_object.rs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing support for success_action_status and success_action_redirect in S3 POST uploads

2 participants