Skip to content

Incorrect FirebaseError for malformed doc() invocation #9378

@NNskelly

Description

@NNskelly

Operating System

Windows 11

Environment (if applicable)

Node.js 22.14.0

Firebase SDK Version

@firebase/firestore 4.9.2

Firebase SDK Product(s)

Firestore

Project Tooling

Simple raw NodeJS script; no build tooling

Detailed Problem Description

when the first argument to a doc() call is undefined, the console spits out
FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore

Guessing this is either a one-line copypasta oversight, or a common handler that needs to be rephrased.

Steps and code to reproduce issue

Sans any other error reporting, it took some digging to uncover that the culprit in my current instance was in fact one new doc(firestore,docpath) call where I had neglected to initialize firestore, not any of the several actual collection(firestore,collectionpath) calls.
If simply including { doc, getDoc }, creating a doc reference with an undefined first argument, and awaiting getDoc is not enough to repro, I likely cannot include any more code due to NDA and project timelines.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions