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

firestore: detect-project-id overrides the emulator #1751

Closed
joeholley opened this issue Jan 27, 2020 · 4 comments · Fixed by #2598
Closed

firestore: detect-project-id overrides the emulator #1751

joeholley opened this issue Jan 27, 2020 · 4 comments · Fixed by #2598
Assignees
Labels
api: firestore Issues related to the Firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@joeholley
Copy link

Client

Firestore

Environment

  • gcloud cloud-firestore-emulator 1.10.2 running with command
    gcloud beta emulators firestore start --host-port "localhost:8081"
  • Linux runtime environment, bash shell with
    export FIRESTORE_EMULATOR_HOST=localhost:8081
  • latest golang firestore server client

Code

        client, err = firestore.NewClient(context.Background(),
            "*detect-project-id*",
            options...)                                                                                                                                                                  
        if err != nil {
            return err 
        }   

Expected behavior

By default, the client lib ignores the specified Firestore project ID in a NewClient() call when it detects an emulator is running (i.e. FIRESTORE_EMULATOR_HOST env var is set) ... unless the project ID is set to the "*detect-project-id*" sentinel value. It should check for the emulator env var before checking for the "*detect-project-id*" project ID sentinel value, and ignore this value in the same way as it ignores any other project ID value. Developers using the sentinel value to auto-detect projects when running their code in GCP should not need to modify their code/configuration to use a different project ID value when using the local emulator. (I'm guessing that was the intended behavior, since it is ignored for every other value.)

Actual behavior

When the sentinel value is used, the attempt to instantiate the client throws the following error:
firestore: see the docs on DetectProjectID

Screenshots

N/A

Additional context

None

@joeholley joeholley added the triage me I really want to be triaged. label Jan 27, 2020
@tbpg tbpg changed the title packagename: short description of bug firestore: detect-project-id overrides the emulator Jan 27, 2020
@tbpg tbpg added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. api: firestore Issues related to the Firestore API. and removed triage me I really want to be triaged. labels Jan 27, 2020
@rHermes
Copy link

rHermes commented Feb 3, 2020

I have submitted a pull request here that fixes this. It's been there for 4 days now and no comments, so I am not sure if I've done it right.

https://code-review.googlesource.com/c/gocloud/+/51250

@tbpg
Copy link
Contributor

tbpg commented Feb 3, 2020

Thank you for sending it! I just responded on the CL, but I'd like to get one other review before merging.

@rHermes
Copy link

rHermes commented Feb 19, 2020

Has there been any progress on this?

@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels May 19, 2020
broady added a commit that referenced this issue Jul 14, 2020
We can use a blank project ID when the emulator is being used.

Emulator access is unauthenticated, so there's no sense in looking at
the credentials to detect the project ID.

Fixes #1751.
broady added a commit that referenced this issue Jul 14, 2020
We can use any project ID when the emulator is being used.

Try to look detect a real-looking one, and fallback to a dummy ID.

Fixes #1751.
broady added a commit that referenced this issue Jul 14, 2020
We can use any project ID when the emulator is being used.

Try to look detect a real-looking one, and fallback to a dummy ID.

Fixes #1751.
broady added a commit that referenced this issue Jul 14, 2020
We can use any project ID when the emulator is being used.

Try to look detect a real-looking one, and fallback to a dummy ID.

Fixes #1751.
@tritone
Copy link
Contributor

tritone commented Jul 15, 2020

@rHermes apologies for the very belated response on this. @broady has a PR up with a fix if you'd like to take a look. #2598

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Jul 25, 2020
tritone added a commit that referenced this issue Jul 29, 2020
We can use any project ID when the emulator is being used.

Try to look detect a real-looking one, and fallback to a dummy ID.

Fixes #1751.

Co-authored-by: Chris Cotter <cjcotter@google.com>
tritone added a commit to tritone/google-cloud-go that referenced this issue Aug 25, 2020
…pis#2598)

We can use any project ID when the emulator is being used.

Try to look detect a real-looking one, and fallback to a dummy ID.

Fixes googleapis#1751.

Co-authored-by: Chris Cotter <cjcotter@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the Firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants