Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated code doesn't work for Firestore #17

Open
xJonathanLEI opened this issue Sep 22, 2021 · 5 comments
Open

Generated code doesn't work for Firestore #17

xJonathanLEI opened this issue Sep 22, 2021 · 5 comments

Comments

@xJonathanLEI
Copy link

The Firestore API requires building request URLs in the format of v1/{parent}/databases, where parent takes the form of projects/{project_id}.

The code generated by this generator URL-encodes this parent param like so:

let rel_path = format!(
    "v1/{parent}/databases",
    parent = percent_encode(format!("{}", params.parent).as_bytes(), NON_ALPHANUMERIC)
);
let path = self.format_path(rel_path.as_str());

Therefore, the request path becomes:

/v1/projects%2Fproject_id/databases

whereas it should be:

/v1/projects/project_id/databases

This mis-handling of URL is causing 404 errors.

@xJonathanLEI
Copy link
Author

For context, the code was generated with:

./generate.py --apis=firestore:v1

@dermesser
Copy link
Owner

I will try to take a look soon. In the meantime, you're welcome to try it out yourself -- but I understand if it's not an option, the python code can be a bit complex :)

@dermesser
Copy link
Owner

Sorry for forgetting so long about this - is this still an issue for you, or have you found a workaround?

@xJonathanLEI
Copy link
Author

Hey thanks for picking this up again :)

I haven't tested but I guess the issue must still be there? Given there has been no code update since the issue was created.

I have been using a workaround: modifying the generated code to not do the percent_encode on parent and it works well (though it might only work when there's no special character in project_id I guess).

@dermesser
Copy link
Owner

Got it - I was asking in case you'd given up on this code and rolled something yourself :)

I guess a quick fix is to attempt encoding anything but the slash characters; I am also not sure why it doesn't work in the first place, as I was under the impression that url-encoded characters should be decoded (but I guess Google takes some parameters literally). The hope would be that this doesn't break another API which can't deal with unencoded slashes in the wrong place :-]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants