-
Notifications
You must be signed in to change notification settings - Fork 148
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
Error getting documents: Error: 9 FAILED_PRECONDITION when using collectionGroup #1866
Comments
I suspect you are using OAuth 2.0. See: https://firebase.google.com/docs/admin/setup Note: OAuth 2.0 refresh tokens are not supported for connecting to Cloud Firestore. |
I found the issue. All I had to do is to use |
I think that the main issue here is that the FAILED_PRECONDITION error is not including create query index -link. |
My firebase-admin: ^11.10.1 Same problem running this code snippet in a deployed code: static async getAllByIdProduct(id: string) {
const query = await firestore
.collectionGroup("modelos")
.where("idsDeProduto", "array-contains", id)
.get();
return query.docs.map(doc => ({
data: doc.data() as RoteiroModelDTO,
ref: doc.ref as DocumentReference<RoteiroModelDTO>,
}));
} Error in GCP: It really seems that the link to create the indexes should come, but it's just showing a generic error |
Thank you for this additional information. @tom-andersen will follow up early next week. |
Update: @leonardopn I verified the server logs, and the error message describing the problem along with link to create index was provided. But somewhere from the time that response is sent to cloud function and the output being logged, the error message is being stripped out. I see no reason for why the SDK should do this, so I wonder if there is something in the logging setup that causes this. If you run the query locally on your development machine, I imagine the error with link should appear. I will see if I can reproduce error with cloud function. |
We still don't know why the text is stripped from the error. However, the resolution remains the same. Create the required composite index. For now you will need to run the code locally (or not within cloud function), and then there will be a helpful link as part of error. |
Running into this also. As an alternative to running the query locally, I was able to get the index creation link by using the GCP Console with the Query Builder. But even if the link wasn't generated via that method, it does allow you to quickly test if a particular query would be supported, and then manually go through the process of adding the index in the GCP Console. |
This is absolutely ridiculous, you can't warn us when developing and you 'don't know why the text is stripped from the error', so we can't even set up a proper alert in case a missing index gets through to production. Come on Google, do better. |
I was referred here by GCP support - which we pay for - so it's extra frustrating to see that a repeatable issue affecting basic functionality is known but receiving no attention. GCP support also referred me to this likely related issue that has been open since 2022. It is impossible for me to believe that with all the smart people I know at Google that no one can figure out why an error message is getting truncated. So when can we expect a resolution for this? I know no one the support team is going to lose sleep if we leave Firebase, but we have had so many similar Firebase support experiences - long open issues with basic functionality - that it's increasingly hard to believe that GCP sees Firebase as a priority. |
I believe that the issue should receive higher priority. It seems to have slipped through the cracks, and the team isn't really aware of the problem. Not being able to receive the index link makes the collection group's DX hellish. Let's alone say we have to deploy to production and hope to catch the errors before users do, but we also have to guess which query is failing. @MarkDuckworth forgive me for pinging you. I can see your commits in the main branch, so hopefully, you can access the actual issue priority. |
Hi @kossnocorp, I am trying to move this forward, since this has somewhat fallen between teams. So here are some updates:
When we know more, I will update this issue. |
I’m fairly certain this is not related to Firebase functions as I am having
the problem while using Next.JS to query Firestore.
…On Tue, Apr 30, 2024 at 12:30 PM Tom Andersen ***@***.***> wrote:
Hi @kossnocorp <https://github.com/kossnocorp>,
I am trying to move this forward, since this has somewhat fallen between
teams. So here are some updates:
1. Logging is not the cause. The text message is stripped before
exception is emitted as part of Firebase Function.
2. I have produced a reproduction and shared it with Firebase
Functions. They will investigate whether this happens as part of Firebase
Function or further back in the system under a Cloud Function. Someone from
FIrebase Functions will investigate further.
When we know more, I will update this issue.
—
Reply to this email directly, view it on GitHub
<#1866 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOMZ7SGJKLDDBK5SJBMESDY77IMXAVCNFSM6AAAAAA2XF5LCSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBWGE2DMMRRHA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
This problem sometimes occurs in NodeJS 18 and 20, but not 16 from our observation. For Cloud Functions and Firebase Functions, reducing the engine to NodeJS version 16 removes the problem. |
this fixed it for me. |
I've been a Firebase user since 2016. This error did not include the link to create the missing index, making it difficult to manually create this collection group index. This worked in the emulator, but in production, it failed because the emulator doesn't use indexes. Not having the link resulted in an unnecessary time sink. I'm lucky to have known what query I added and prior projects I could take the collection group index out to modify for this new application I was working on.
|
Agree. I'm having the same issue today and the error log is not helpful. |
I am still experiencing this issue today. It is not possible to create the index through the logs. |
@dumitruPuggle thank you so much, I had the same issue - no |
Environment details
@google-cloud/firestore
version: I was told to come to this repo to get the responses quickly, although I'm using firestore-admin 11.9.0Steps to reproduce
I created the necessary indexes on Firestore Console:
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!
The text was updated successfully, but these errors were encountered: