Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
how can i handle invalid document reference error in firestore v9

i am currently working on chat app , but when i got to the chat component, i have been having this error when i tried submitting the chat into the firestore database that i created with a collection called channels

this is my code below;

const sendMessage = async (e) => {
    e.preventDefault();
    let input = inputRef.current.value;
    if (input !== "") {
      const messagesRef = doc(db, "channels", channelId, "messages");
      const payload = {
        timestamp: serverTimestamp(),
        message: inputRef.current.value,
        name: user?.displayName,
        photoURL: user?.photo,
        email: user?.email,
      };
      await addDoc(messagesRef, payload);
    }

when i click on the submit button to create that document i get this error below.

Unhandled Rejection (FirebaseError): Invalid document reference. Document references must have an even number of segments, but channels/8jIExW7vKcXJRJdmq9b3/messages has 3.

i have been trying to seek help but i have not gotten since 3 days now.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!