You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An orphaned top-level comments collection exists in the v-threads Firestore database using a schema the current code never reads or writes. It stores author email addresses in plaintext.
What is in the database
A document in the top-level comments collection:
authorEmail: "devdatta.talele@vit.edu.in"
authorId: "FwpgHCL6CfgGuKhnVY5cwGODI022"
authorName: "Devdatta"
body: "hi"
postId: "1"
timestamp: 9 June 2025 at 13:44:51 UTC+5:30
What the current code expects
Comments are written to and read from a subcollection, not a top-level collection, with entirely different field names:
src/lib/services/commentService.ts:19 — writes to `questions/${questionId}/comments`
src/lib/services/commentService.ts:41 — reads from the same subcollection path
src/lib/types.ts:45-56 — the Comment interface: content, author (a nested UserProfile object), parentId, createdAt, upvotes, downvotes
Mapping the two against each other:
Legacy top-level field
Current schema
body
content
authorEmail / authorId / authorName
author object
timestamp
createdAt
postId: "1"
questionId, a Firestore auto-ID
—
parentId, upvotes, downvotes (absent in legacy)
postId: "1" is a sequential integer, whereas questions today use Firestore auto-IDs, so these documents predate the current data model and cannot be joined to any existing question.
It is invisible to the app. No code path reads the top-level comments collection, so these comments render nowhere. Anyone browsing the database will reasonably assume it is live data.
If the data is not needed (likely — it is a single "hi" test comment from an earlier prototype): delete the top-level comments collection.
If it should be preserved: export it first, then delete. Do not attempt to migrate it into questions/{id}/comments unless postId can be mapped to a real question ID, which appears impossible given the ID scheme changed.
Either way, confirm the deployed firestore.rules denies access to this path so it cannot be read while the decision is pending.
Verification note
Found by inspecting the Firestore console. Worth auditing the other collections for the same problem — check whether votes contains documents under the legacy flat scheme as well as the votes/{type}/{itemId}/{uid} path the current voteService.ts uses, since a schema change of this kind rarely affects only one collection.
An orphaned top-level
commentscollection exists in thev-threadsFirestore database using a schema the current code never reads or writes. It stores author email addresses in plaintext.What is in the database
A document in the top-level
commentscollection:What the current code expects
Comments are written to and read from a subcollection, not a top-level collection, with entirely different field names:
src/lib/services/commentService.ts:19— writes to`questions/${questionId}/comments`src/lib/services/commentService.ts:41— reads from the same subcollection pathsrc/lib/types.ts:45-56— theCommentinterface:content,author(a nestedUserProfileobject),parentId,createdAt,upvotes,downvotesMapping the two against each other:
bodycontentauthorEmail/authorId/authorNameauthorobjecttimestampcreatedAtpostId: "1"questionId, a Firestore auto-IDparentId,upvotes,downvotes(absent in legacy)postId: "1"is a sequential integer, whereas questions today use Firestore auto-IDs, so these documents predate the current data model and cannot be joined to any existing question.Why this matters
Three separate reasons:
authorEmailis stored in a collection nothing reads. Until real security rules are deployed the collection is world-readable, so it is an email address exposed for no functional benefit. (See Ship firestore.rules and move privileged writes to the Admin SDK #16 for the rules problem, Stop denormalizing full UserProfile into question/comment/event docs #23 for the same issue in live collections.)commentscollection, so these comments render nowhere. Anyone browsing the database will reasonably assume it is live data.firestore.rulesis written (Ship firestore.rules and move privileged writes to the Admin SDK #16), this collection needs an explicit decision — deny it, or migrate it — rather than being silently covered by a catch-all.Suggested fix
Decide and act, rather than leaving it:
"hi"test comment from an earlier prototype): delete the top-levelcommentscollection.questions/{id}/commentsunlesspostIdcan be mapped to a real question ID, which appears impossible given the ID scheme changed.Either way, confirm the deployed
firestore.rulesdenies access to this path so it cannot be read while the decision is pending.Verification note
Found by inspecting the Firestore console. Worth auditing the other collections for the same problem — check whether
votescontains documents under the legacy flat scheme as well as thevotes/{type}/{itemId}/{uid}path the currentvoteService.tsuses, since a schema change of this kind rarely affects only one collection.