Description
In Govt-Billing-React/src/firebase/firestore.ts, the downloadFileFromFirebase function retrieves a document from Firestore and attempts to mutate it without verifying if the document actually exists.
Impact
If a user attempts to download a file that has been deleted from another device, or if there is a network/permission desync, docSnapshot.data() will return undefined. Attempting to execute delete data["owner"] on an undefined object will cause a fatal JavaScript runtime error, crashing the application thread silently.
Proposed Solution
Add an explicit docSnapshot.exists() validation check inside the getFile helper function. If the document does not exist, throw a controlled error so it can be handled gracefully by the parent try...catch block.
Description
In
Govt-Billing-React/src/firebase/firestore.ts, thedownloadFileFromFirebasefunction retrieves a document from Firestore and attempts to mutate it without verifying if the document actually exists.Impact
If a user attempts to download a file that has been deleted from another device, or if there is a network/permission desync,
docSnapshot.data()will returnundefined. Attempting to executedelete data["owner"]on anundefinedobject will cause a fatal JavaScript runtime error, crashing the application thread silently.Proposed Solution
Add an explicit
docSnapshot.exists()validation check inside thegetFilehelper function. If the document does not exist, throw a controlled error so it can be handled gracefully by the parenttry...catchblock.