Bug
Fresh deployments fail with FirebaseError: The query requires an index on multiple pages (Dashboard, Cashflow, Patrimonio) due to three issues in firestore.indexes.json.
Issues found
1. monthly-snapshots — wrong sort order
The index defines year and month as DESCENDING, but snapshotService.ts queries with orderBy('year', 'asc'), orderBy('month', 'asc'). Firestore treats these as different indexes and refuses to serve the query.
2. expenses — index missing
expenseService.ts queries expenses filtered by userId and ordered by date DESCENDING, but no corresponding composite index exists in the file.
3. expenseCategories — index missing
expenseCategoryService.ts queries expenseCategories filtered by userId and ordered by name ASCENDING, but no corresponding composite index exists in the file.
Fix
{
"indexes": [
{
"collectionGroup": "monthly-snapshots",
"queryScope": "COLLECTION",
"fields": [
{ "fieldPath": "userId", "order": "ASCENDING" },
{ "fieldPath": "year", "order": "ASCENDING" },
{ "fieldPath": "month", "order": "ASCENDING" }
]
},
{
"collectionGroup": "expenses",
"queryScope": "COLLECTION",
"fields": [
{ "fieldPath": "userId", "order": "ASCENDING" },
{ "fieldPath": "date", "order": "DESCENDING" }
]
},
{
"collectionGroup": "expenseCategories",
"queryScope": "COLLECTION",
"fields": [
{ "fieldPath": "userId", "order": "ASCENDING" },
{ "fieldPath": "name", "order": "ASCENDING" }
]
}
]
}
Steps to reproduce
- Clone the repo and follow the setup guide
- Run
firebase deploy --only firestore:indexes
- Open the app — Dashboard, Cashflow and Patrimonio pages show query index errors in the browser console
Environment
Discovered on a fresh Firebase project (europe-west1) following the official SETUP.md.
Bug
Fresh deployments fail with
FirebaseError: The query requires an indexon multiple pages (Dashboard, Cashflow, Patrimonio) due to three issues infirestore.indexes.json.Issues found
1.
monthly-snapshots— wrong sort orderThe index defines
yearandmonthasDESCENDING, butsnapshotService.tsqueries withorderBy('year', 'asc'), orderBy('month', 'asc'). Firestore treats these as different indexes and refuses to serve the query.2.
expenses— index missingexpenseService.tsqueriesexpensesfiltered byuserIdand ordered bydate DESCENDING, but no corresponding composite index exists in the file.3.
expenseCategories— index missingexpenseCategoryService.tsqueriesexpenseCategoriesfiltered byuserIdand ordered byname ASCENDING, but no corresponding composite index exists in the file.Fix
{ "indexes": [ { "collectionGroup": "monthly-snapshots", "queryScope": "COLLECTION", "fields": [ { "fieldPath": "userId", "order": "ASCENDING" }, { "fieldPath": "year", "order": "ASCENDING" }, { "fieldPath": "month", "order": "ASCENDING" } ] }, { "collectionGroup": "expenses", "queryScope": "COLLECTION", "fields": [ { "fieldPath": "userId", "order": "ASCENDING" }, { "fieldPath": "date", "order": "DESCENDING" } ] }, { "collectionGroup": "expenseCategories", "queryScope": "COLLECTION", "fields": [ { "fieldPath": "userId", "order": "ASCENDING" }, { "fieldPath": "name", "order": "ASCENDING" } ] } ] }Steps to reproduce
firebase deploy --only firestore:indexesEnvironment
Discovered on a fresh Firebase project (europe-west1) following the official SETUP.md.