RedHatInsights / floorist

Floorist is a simple script to dump SQL queries from a PostgreSQL database into S3 buckets in parquet format.
Apache License 2.0
2 stars 9 forks source link

There's no proper handling for not YAML formatted floorplan files #3

Open Victoremepunto opened 3 years ago

Victoremepunto commented 3 years ago

The parser tries to open it as a yaml, reading lines expecting having the right format, which is not safe, this raises exceptions when the format is not the expected:

 ERROR    root:floorist.py:55 string indices must be integers
 Traceback (most recent call last):
   File "/opt/app-root/lib64/python3.9/site-packages/floorist/floorist.py", line 34, in main
     logging.debug(f"Dumping #{dump_count}: {row['query']} to {row['prefix']}")
 TypeError: string indices must be integers

This is reproducible just by passing a file with a random string as a content ( empty files also causes #2 )

skateman commented 3 years ago

What kind of error would you like to see here? What's the right behavior?

Victoremepunto commented 3 years ago

@skateman I would expect the parser to check if the file is a well formatter YAML file, I guess there must be a way to parse the YAML to check the syntax, so we validate it before we start reading it.