s3 icon indicating copy to clipboard operation
s3 copied to clipboard

URI escape invalid

Open kallisti5 opened this issue 2 years ago • 3 comments

/home/kallisti5/.gem/ruby/3.0.0/gems/s3-0.3.29/lib/s3/bucket.rb:154:in `list_bucket': undefined method `escape' for URI:Module (NoMethodError)
	from /home/kallisti5/.gem/ruby/3.0.0/gems/s3-0.3.29/lib/s3/bucket.rb:115:in `block in objects'
	from /home/kallisti5/.gem/ruby/3.0.0/gems/proxies-0.2.3/lib/proxies/proxy.rb:58:in `proxy_target'
	from /home/kallisti5/.gem/ruby/3.0.0/gems/proxies-0.2.3/lib/proxies/proxy.rb:62:in `method_missing'
	from ./nightly-reaper-s3.rb:37:in `<main>'

kallisti5 avatar Feb 17 '22 14:02 kallisti5

Yeah, it seems some changes are required in order to launch it on Ruby 3.0.

Could you create a PR?

qoobaa avatar Feb 18 '22 07:02 qoobaa

I was able to work around the issue locally:

--- /home/kallisti5/.gem/ruby/3.0.0/gems/s3-0.3.29/lib/s3/bucket.rb.original	2022-02-18 13:26:37.247078560 -0600
+++ /home/kallisti5/.gem/ruby/3.0.0/gems/s3-0.3.29/lib/s3/bucket.rb	2022-02-18 13:26:47.707146732 -0600
@@ -151,7 +151,7 @@
       # If there are more than 1000 objects S3 truncates listing and
       # we need to request another listing for the remaining objects.
       while parse_is_truncated(response.body)
-        next_request_options = {:marker => URI.escape(objects_attributes.last[:key])}
+        next_request_options = {:marker => URI::DEFAULT_PARSER.escape(objects_attributes.last[:key])}
 
         if max_keys
           break if objects_attributes.length >= max_keys

That's likely not a good fix though since it might break for Ruby 2.x / stdlib 2.x.

Really surprised Ruby didn't leave some compatibility .escape call in the api :-|

kallisti5 avatar Feb 18 '22 19:02 kallisti5

I opened https://bugs.ruby-lang.org/issues/18593 maybe the real solution is Ruby 3.x should have been less aggressive in refactoring escape :-)

kallisti5 avatar Feb 18 '22 19:02 kallisti5