aiogoogle icon indicating copy to clipboard operation
aiogoogle copied to clipboard

URL formatting issue

Open dmitry-engineer opened this issue 3 years ago • 2 comments

Since v4.2.0 I'm getting 404 error when I try to get a secret version from the Secret Manager. The error message looks like

404. That’s an error.

The requested URL /v1/projects%2Fproject%2Fsecrets%2Fmy-secret%2Fversions%2Flatest:access was not found on this server. That’s all we know.

I believe the issue is that some of functions in the library replaces / with %2F If I use Aiogoogle v4.1.0 - everything is OK

dmitry-engineer avatar Aug 18 '22 13:08 dmitry-engineer

Request looks like

response = await aiogoogle.as_service_account(secret_manager.projects.secrets.versions.access(
                name=f'projects/{project_id}/secrets/{secret_id}/versions/{version_id}'
            ))

dmitry-engineer avatar Aug 18 '22 13:08 dmitry-engineer

Hi @dmitry-engineer Thanks for raising the issue.

I've taken a look at some of the previous issues regarding this bug. We've had 2 issues and 2 PRs concerning this issue i.e. encode forward slash vs not encode. At first we were encoding it, then this issue and subsequently a PR was created https://github.com/omarryhan/aiogoogle/issues/63. Then not encoding forward slashes caused this issue: https://github.com/omarryhan/aiogoogle/issues/96 which reverted #63

I honestly have no idea which method should be the default, would you mind checking which method Google's official Python lib uses (https://github.com/googleapis/google-api-python-client)? I think we should stick to how they handle it by default.

If it's not clear how Google api client does it, then I think not encoding forward slashes is the better solution because a user can always manually encode it before passing it to aiogoogle, however, it will be harder to do the reverse once it's passed to this lib.

Thanks!

omarryhan avatar Aug 19 '22 01:08 omarryhan

Fixed in v5.0.0, please reopen if you're still facing the same issue, thanks!

omarryhan avatar Dec 20 '22 21:12 omarryhan