emmercm / igir

🕹 A zero-setup ROM collection manager that sorts, filters, extracts or archives, patches, and reports on collections of any size on any OS.
https://igir.io/
GNU General Public License v3.0
363 stars 18 forks source link

Crash when processing certain libretro dats #781

Closed juliadin closed 11 months ago

juliadin commented 11 months ago

Paste the command

igir report --dat dat/libretro-database/dat/Sony\ -\ PlayStation\ 3.dat --input sources/

Describe the bug

When using igir (tried with some 1.9, 2.0.6, 2.0.7) to process some files in the libretro-database repository, it crashes with an unhelpful error:

 ______   ______   ______  _______  
|      \ /      \ |      \|       \ 
 \$$$$$$|  $$$$$$\ \$$$$$$| $$$$$$$\
  | $$  | $$|    \  | $$  | $$    $$   ROM collection manager
  | $$  | $$|    \  | $$  | $$    $$   https://igir.io/
  | $$  | $$ \$$$$  | $$  | $$$$$$$\
 _| $$_ | $$__| $$ _| $$_ | $$  | $$   v2.0.7
|   $$ \ \$$    $$|   $$ \| $$  | $$
 \$$$$$$  \$$$$$$  \$$$$$$ \$$   \$$

↻ Scanning for DATs ·········· | ░░░░░░░░░░░░░░░░░░░░░░░░░ | 0/1file:///usr/local/lib/node_modules/igir/build/src/modules/datScanner.js:277
                    .filter((rom) => rom.name) // we need ROM filenames
                     ^

TypeError: Cannot read properties of undefined (reading 'filter')
    at file:///usr/local/lib/node_modules/igir/build/src/modules/datScanner.js:277:22
    at Array.flatMap (<anonymous>)
    at DATScanner.<anonymous> (file:///usr/local/lib/node_modules/igir/build/src/modules/datScanner.js:274:38)
    at Generator.next (<anonymous>)
    at fulfilled (file:///usr/local/lib/node_modules/igir/build/src/modules/datScanner.js:4:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.13.0

At the moment it happens with the files

libretro-database/dat/Nintendo - GameCube.dat
libretro-database/dat/Nintendo - Super Nintendo Entertainment System.dat
libretro-database/dat/Nintendo - Wii.dat
libretro-database/dat/Nintendo - Wii U.dat
libretro-database/dat/PuzzleScript.dat
libretro-database/dat/Sinclair - ZX Spectrum.dat
libretro-database/dat/Sony - PlayStation 3.dat
libretro-database/dat/Vircon32.dat
libretro-database/dat/WASM-4.dat

from the repository https://github.com/libretro/libretro-database.git

Expected behavior

processing of the dat files or warnings about issues with the contained data

Debug logs

 ______   ______   ______  _______  
|      \ /      \ |      \|       \ 
 \$$$$$$|  $$$$$$\ \$$$$$$| $$$$$$$\
  | $$  | $$|    \  | $$  | $$    $$   ROM collection manager
  | $$  | $$|    \  | $$  | $$    $$   https://igir.io/
  | $$  | $$ \$$$$  | $$  | $$$$$$$\
 _| $$_ | $$__| $$ _| $$_ | $$  | $$   v2.0.7
|   $$ \ \$$    $$|   $$ \| $$  | $$
 \$$$$$$  \$$$$$$  \$$$$$$ \$$   \$$

[16:46:42.694] INFO:  DATScanner: scanning DAT files
[16:46:42.720] DEBUG: DATScanner: found 1 DAT file
[16:46:42.721] DEBUG: DATScanner: enumerating DAT archives
↻ Scanning for DATs ·········· | ░░░░░░░░░░░░░░░░░░░░░░░░░ | 0/1file:///usr/local/lib/node_modules/igir/build/src/modules/datScanner.js:277
                    .filter((rom) => rom.name) // we need ROM filenames
                     ^

TypeError: Cannot read properties of undefined (reading 'filter')
    at file:///usr/local/lib/node_modules/igir/build/src/modules/datScanner.js:277:22
    at Array.flatMap (<anonymous>)
    at DATScanner.<anonymous> (file:///usr/local/lib/node_modules/igir/build/src/modules/datScanner.js:274:38)
    at Generator.next (<anonymous>)
    at fulfilled (file:///usr/local/lib/node_modules/igir/build/src/modules/datScanner.js:4:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.13.0

DAT(s) used

https://raw.githubusercontent.com/libretro/libretro-database/master/dat/Sony%20-%20PlayStation%203.dat

igir version

2.0.7

Node.js version

18.13.0

Operating system

Debian 12

Additional context

No response

emmercm commented 11 months ago

This is being caused by https://github.com/RobLoach/datfile/issues/2. I can add a workaround so the parsing doesn't crash like this, but the CMPro DAT parser may need a rewrite.

juliadin commented 11 months ago

Thanks for the swift explanation. A workaround would be nice since I needed to do 'nop' runs of igir just to fidn the files that failed. Throwing an error that states the file name if dat parsing fails would be wonderful.

github-actions[bot] commented 10 months ago

:lock: Inactive issue lock

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Comment generated by the GitHub Lock Issues workflow.