Directory.list can return an empty object. However, our frontend expects an empty array (it calls val.map), which causes it to crash on an empty object returned.
Solution
Change the default empty object return to empty array. this is safe because the call sites for Directory.list uses a .reduce with [] as the base acc, showing that they expect empty array (<Collection | Subfolder>.js). The callsite in directory.js also uses an empty array as the base if there's an error thrown during .list (this bug might appear there too).
Testing
[ ] Deploy this branch to staging (or run it on local w/ your FE)
Problem
Directory.list
can return an empty object. However, our frontend expects an empty array (it callsval.map
), which causes it to crash on an empty object returned.Solution
Change the default empty object return to empty array. this is safe because the call sites for
Directory.list
uses a.reduce
with[]
as the base acc, showing that they expect empty array (<Collection | Subfolder>.js
). The callsite indirectory.js
also uses an empty array as the base if there's an error thrown during.list
(this bug might appear there too).Testing
staging
(or run it on local w/ your FE)moe-cantonmenpri
verified by @kishore03109