-
Notifications
You must be signed in to change notification settings - Fork 155
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
Firebase Storage Emulator Support #752
Comments
Hi, thanks for filing this. As you noted, python admin SDK support is planned but we can't provide any hard dates as to when it will be available. We can keep this issue open to track any work that's being done but as always, we welcome any and all community contributions. If someone wants to take a stab at this, we will be more than happy to provide guidance and reviews. |
Thank you @qhaas for a good minimal reproduction script. I dug in a little bit; I am by no means an expert in this code base, so it took a lot of Uploading a fileThe emulator expects a
This accounts for the (first) HTTP 400. Proposed patch here. Further downstream, the storage emulator breaks apart the multi-part upload by checking the boundary string provided in the header, but it errors out here again (
The docstring in the emulator strongly suggests it doesn't expect a boundary string with quotes like this. Since a quoted-string is a valid boundary, this seems like a bug in emulator code. Proposed patch here. Next error: Updating ACL (make_public)Got a 404:
I think what may be happening here is that there is no I'm not sure what to do here. The emulator does not support ACL rules, so I don't want to create a route just to make the client happy. The nodejs client avoids this by not GETting the ACL when it needs to update the rule, so this may be a limitation on the python client. Downloading a fileSeems to work okay on my setup. Deleting a file
There are two options here; change the client to use a URL the emulator can handle (it looks like it can handle It feels like adding an alias to that route is the lowest risk and can potentially fix other similar issues (firebase/firebase-tools#3508 (comment)). Proposed patch here. If these approaches make sense, I can make a PRs in firebase-tools and python-storage to proceed with the fixes. There are still some outstanding issues to go:
|
@tonyjhuang I opened a couple PRs to fix these issues #761 firebase/firebase-tools#4423), but I'm currently looking for a thumbs up before unmarking as draft. |
I've been using these branches of the Firebase emulator and the python admin SDK for 4 months internally with no issue, so I'm unmarking these PRs as draft. |
Hi @jack-michaud I've been working through some python gcs sdk issues on the storage emulator and I merged in some changes to strip quotes (firebase/firebase-tools#4825) and to make content type case insensitive (firebase/firebase-tools#4824). |
Thank you @Yuangwang! I will add tests to those changes. Also, this may be outside of your purview, but have you taken a look at #761? This fix is required for file uploads from python to work with the storage emulator. |
@jack-michaud I also pushed a change recently to have the storage emulator fallback on reading the name from the file metadata (firebase/firebase-tools#4832). I tested it with the python gcs sdks and it should fix the upload issue you mentioned! |
Hi @jack-michaud this pr should be a good reference for where the tests should go https://github.com/firebase/firebase-tools/pull/5209/files. Looking at the commits you linked again I think the additional get route was added in another pr, so the only one to add would be the delete one (jack-michaud/firebase-tools@c0045d9) It looks like our test coverage is actually a bit weak here for delete so we don't have a testcase for the flow yet. To add one you could do something like: Feel free to take a stab at it, but we're also happy to create our own pr to get in the new route + test changes since the coverage was missing to begin with. Let me know if you take a stab at it, otherwise we can make the pr in the coming weeks |
Thank you for your comment... I deleted my comment when I found that exact PR and saw that there was a test associated with it. So I'm adding the test for Delete! Thank you for your kindness in searching for that on my behalf. |
Do we have any update on this? |
Same error here:
|
I'll pick this back up when I have some time over the next week. I remember getting a little confused when trying to find an existing test to pull inspiration from. I'll try to find the existing test code that tests these code path again. |
Update: all new changes in my PR were integrated by a separate author adding support for the V1 API in b0798fb1fe -- so deletion should now work. From my notes it seems like the only thing the client does not support yet is ACL rules, but the last I checked emulator itself doesn't support ACL rules. |
Summary:
Allow use of Firebase storage emulators via the
google.cloud.storage
API.Background:
As Firebase developers, we often use the Firebase emulator suite during development. Given Firebase is hosted on Google Cloud (GC), many features run on said GC and are compatible with GC APIs. The Firebase Storage Emulator lacks python client and admin bindings, python admin support is planned, but no word on when it will be available. The admin sdk is overkill for our use case since we just want to upload / download files with python.
Apparently, third party GC storage emulators are supported by the GC python-storage API (see #376, #324). Given we already use the python-storage API to interact with the GC hosted Firebase, it seems reasonable it should also support Google's own Firebase Storage emulator like it does said third-party GC Storage emulators. It is possibly related to this Firebase Storage emulator issue.
Example with Google Cloud:
Consider this snippet, it works fine with our Google Cloud hosted Firebase project.
The following environment variables were set:
GOOGLE_APPLICATION_CREDENTIALS
: Path to PKI fileGCP_PROJECT
: GC hosted Firebase Project IDOutput indicates everything worked fine:
Example with Firebase Storage Emulator:
When setting the
STORAGE_EMULATOR_HOST
andFIREBASE_STORAGE_EMULATOR_HOST
to point the client at the Firebase storage emulator's host and port (e.g.http://localhost:9199
, I getInvalidResponse
,Bad Request: ('Request failed with status code', 400, 'Expected one of', <HTTPStatus.OK: 200>)
, etc. in the resulting stack traces.The Firebase Storage emulator is working fine since our Android Java Application uses it.
Relevant Software Versions:
Host: x86-64 EL8
google-cloud-storage: 2.2.1
Python: 3.9.6
firebase: 10.5.0
The text was updated successfully, but these errors were encountered: