This is an automated email from the ASF dual-hosted git repository.

Xuanwo pushed a commit to branch xuanwo/fix-s3-presign-append
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit 27e3870d4423b70a3cd5c1e94a3ab726e146228b
Author: Xuanwo <[email protected]>
AuthorDate: Wed Nov 25 17:59:29 2026 +0100

    fix(services/s3): reject append on presigned writes
---
 core/services/s3/src/backend.rs | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/core/services/s3/src/backend.rs b/core/services/s3/src/backend.rs
index 73b964d434..b4ef355bf3 100644
--- a/core/services/s3/src/backend.rs
+++ b/core/services/s3/src/backend.rs
@@ -1585,6 +1585,10 @@ impl Service for S3Backend {
         let req = match op {
             PresignOperation::Stat(v) => 
self.core.s3_head_object_request(path, v),
             PresignOperation::Read(range, v) => 
self.core.s3_get_object_request(path, range, &v),
+            PresignOperation::Write(v) if v.append() => Err(Error::new(
+                ErrorKind::Unsupported,
+                "S3 presigned writes do not support append",
+            )),
             PresignOperation::Write(v) => {
                 self.core
                     .s3_put_object_request(path, None, &v, Buffer::new())
@@ -3750,6 +3754,37 @@ mod tests {
         assert_eq!(builder.config.profile.as_deref(), Some("selected"));
     }
 
+    #[tokio::test]
+    async fn test_presign_write_rejects_append() {
+        let op = Operator::new(
+            S3Builder::default()
+                .bucket("test")
+                .region("us-east-1")
+                .endpoint("http://127.0.0.1:9000";)
+                .access_key_id("test-access-key")
+                .secret_access_key("test-secret-key")
+                .disable_config_load()
+                .disable_ec2_metadata(),
+        )
+        .unwrap();
+        assert!(op.info().capability().write_can_append);
+
+        let result = op
+            .presign_write_options(
+                "test.txt",
+                std::time::Duration::from_secs(60),
+                options::WriteOptions {
+                    append: true,
+                    ..Default::default()
+                },
+            )
+            .await;
+        let Err(err) = result else {
+            panic!("S3 presign must reject append");
+        };
+        assert_eq!(err.kind(), ErrorKind::Unsupported);
+    }
+
     #[tokio::test]
     async fn test_presign_write_omits_checksum_headers() {
         for (algorithm, header_name) in

Reply via email to