googleapis/elixir-google-api

URI.encode/2 bug in objects copy and rewrite

rudebono opened this issue · 1 comments

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Is this a client library issue or a product issue? We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the Support page to reach the most relevant engineers.

If the support paths suggested above still do not result in a resolution, please provide the following details.

Environment details

Steps to reproduce

Example

When copy or rewrite an object, it fails if there is a path in the destination_object.

iex(1)> h GoogleApi.Storage.V1.Api.Objects.storage_objects_rewrite

def storage_objects_rewrite(
  connection,
  source_bucket,
  source_object,
  destination_bucket,
  destination_object,
  optional_params \\ [],
  opts \\ []
)
  • Success
GoogleApi.Storage.V1.Api.Objects.storage_objects_rewrite(
  conn,
  "my_bucket",
  "a/b/c.txt",
  "my_bucket",
  "c.txt" # no path here
)
  • Failed
GoogleApi.Storage.V1.Api.Objects.storage_objects_rewrite(
  conn,
  "my_bucket",
  "a/b/c.txt",
  "my_bucket",
  "a/b/c/c.txt" # path here
)
Reason
solution

change
URI.encode(destination_object, &(URI.char_unreserved?(&1) || &1 == ?/))
to
URI.encode(destination_object, &URI.char_unreserved?/1)

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

This is fixed in #8770. Google Cloud is currently in a release freeze for the holidays in North America. A fixed library will be released next week after the freeze is lifted.