Exercise 3: The Expected Permission Error — Possible Solution ==================================================================== WHY THE CODE FAILS RIGHT NOW ------------------------------ Chapter 1 set up the Firestore database in production mode, which - per this chapter - denies every single read and write by default until Security Rules are written explicitly allowing them. Since Chapter 6 (where those rules actually get written) hasn't happened yet at this point in the course, there are no rules in place granting permission to write to the items collection at all. Firestore's default-deny behavior means the addDoc call in this chapter is rejected with a permission-denied error, regardless of whether the code itself is correct. WHY THIS IS EXPECTED, NOT A BUG ------------------------------ This is the deliberate, secure-by-default behavior of a production-mode Firestore database, not a mistake in this chapter's own code. The addDoc call is written correctly and will work exactly as shown once Chapter 6 supplies the Security Rules that permit it - the failure right now is simply the database doing its job of denying access until it's explicitly told otherwise. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly identifies production-mode Firestore's default-deny behavior as the cause of the permission error, and correctly explains that this reflects the database working as designed rather than any defect in the chapter's own addDoc code.