Skip to content

gcs_get_object fails for filenames with curly braces #195

@AzlinII

Description

@AzlinII

Problem

We have filenames store in gcs with id wrapped in curly braces, something-something-{uniq-id}.json, in the filename (I know that is not ideal but nothing I can do about it). Currently when I try to download any of those files with gcs_get_object it will fail with an error like so:

Error in `"id" %in% names(args)`:
! Could not parse cli `{}` expression: `ec548a47-cc1c-497b-…`.
Caused by error in `parse(text = code, keep.source = FALSE)`:
! <text>:1:18: unexpected symbol
1: ec548a47-cc1c-497b
                     ^

After looking at the code, I see that it's failing this line:

cli::cli_process_start(paste("Downloading", URLdecode(object_name)))

It's trying to interpolate the id within the curly braces. To solve that I tried passing it in as something-something-{{ uniq-id }}.json so that it will work with that line but that causes issues with downloading the actual file since it will now read the file name as something-something-{{ uniq-id }}.json and is getting 404 not found.

Some Suggested solution

  1. Accounting for {} by sanitizing it before passing it into that line without changing the file name. i.e parse the filename and add extra {} when filenames with {} are passed. Preferred solution.

  2. Add option to not print off logs and bypass that line completely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions