You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The copyObject request does not work when the key contains spaces and plus signs. An ObjectNotExistException is thrown.
After looking into the source code, this happens because when the PUT request is made, the BucketData.objectMap sets the keys from the request that is without URL Encoding.
When a normal GET request is made, the BucketData.objectMap request gets the key from the request also without URL Encoding, so it works.
However, when a copyObject request is made, the source key and bucket are written to the x-amz-copy-source header and parsed in CopyObjectController.parseCopyOptions. Here the string includes URL Encoding and is not decoded before being passed to the CopyObjectService, which then passes the same key into the GetObjectService resulting in the exception.
Please let me know if you need more information. I would also be happy to submit a PR for the fix if needed.
Stack trace of exception:
28/Nov. 15:22:58.663 ERROR [defaultEventLoopGroup-4-4] com.robothy.netty.codec.HttpMessageHandler.channelRead0 - - - Failed to handle PUT file-with-encoding.xls: com.robothy.s3.core.exception.ObjectNotExistException: Object key ' file-with-encoding.xls' not exists. at com.robothy.s3.core.asserionts.ObjectAssertions.lambda$assertObjectExists$0(ObjectAssertions.java:18) at java.base/java.util.Optional.orElseThrow(Optional.java:403) at com.robothy.s3.core.asserionts.ObjectAssertions.assertObjectExists(ObjectAssertions.java:18) at com.robothy.s3.core.service.GetObjectService.getObjectFromUnVersionedBucket(GetObjectService.java:35) at com.robothy.s3.core.service.GetObjectService.getObject(GetObjectService.java:28) at com.robothy.s3.core.service.CopyObjectService.copyObject(CopyObjectService.java:26) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at com.robothy.s3.core.service.manager.LocalS3ServicesInvocationHandler.invoke(LocalS3ServicesInvocationHandler.java:38) at jdk.proxy5/jdk.proxy5.$Proxy123.copyObject(Unknown Source) at com.robothy.s3.rest.handler.CopyObjectController.handle(CopyObjectController.java:42) at com.robothy.netty.codec.HttpMessageHandler.channelRead0(HttpMessageHandler.java:46) at com.robothy.netty.codec.HttpMessageHandler.channelRead0(HttpMessageHandler.java:19) at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:61) at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:425) at io.netty.util.concurrent.AbstractEventExecutor.runTask$$$capture(AbstractEventExecutor.java:173) at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java) at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:1583)
The text was updated successfully, but these errors were encountered:
Hello,
The copyObject request does not work when the key contains spaces and plus signs. An ObjectNotExistException is thrown.
After looking into the source code, this happens because when the PUT request is made, the BucketData.objectMap sets the keys from the request that is without URL Encoding.
When a normal GET request is made, the BucketData.objectMap request gets the key from the request also without URL Encoding, so it works.
However, when a copyObject request is made, the source key and bucket are written to the x-amz-copy-source header and parsed in CopyObjectController.parseCopyOptions. Here the string includes URL Encoding and is not decoded before being passed to the CopyObjectService, which then passes the same key into the GetObjectService resulting in the exception.
Please let me know if you need more information. I would also be happy to submit a PR for the fix if needed.
Stack trace of exception:
28/Nov. 15:22:58.663 ERROR [defaultEventLoopGroup-4-4] com.robothy.netty.codec.HttpMessageHandler.channelRead0 - - - Failed to handle PUT file-with-encoding.xls: com.robothy.s3.core.exception.ObjectNotExistException: Object key ' file-with-encoding.xls' not exists. at com.robothy.s3.core.asserionts.ObjectAssertions.lambda$assertObjectExists$0(ObjectAssertions.java:18) at java.base/java.util.Optional.orElseThrow(Optional.java:403) at com.robothy.s3.core.asserionts.ObjectAssertions.assertObjectExists(ObjectAssertions.java:18) at com.robothy.s3.core.service.GetObjectService.getObjectFromUnVersionedBucket(GetObjectService.java:35) at com.robothy.s3.core.service.GetObjectService.getObject(GetObjectService.java:28) at com.robothy.s3.core.service.CopyObjectService.copyObject(CopyObjectService.java:26) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at com.robothy.s3.core.service.manager.LocalS3ServicesInvocationHandler.invoke(LocalS3ServicesInvocationHandler.java:38) at jdk.proxy5/jdk.proxy5.$Proxy123.copyObject(Unknown Source) at com.robothy.s3.rest.handler.CopyObjectController.handle(CopyObjectController.java:42) at com.robothy.netty.codec.HttpMessageHandler.channelRead0(HttpMessageHandler.java:46) at com.robothy.netty.codec.HttpMessageHandler.channelRead0(HttpMessageHandler.java:19) at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:61) at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:425) at io.netty.util.concurrent.AbstractEventExecutor.runTask$$$capture(AbstractEventExecutor.java:173) at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java) at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:1583)
The text was updated successfully, but these errors were encountered: