jmbannon / ytdl-sub

Lightweight tool to automate downloading and metadata generation with yt-dlp
https://ytdl-sub.readthedocs.io
GNU General Public License v3.0
1.7k stars 66 forks source link

Improve invalid yaml error messages #642

Open olinorwell opened 1 year ago

olinorwell commented 1 year ago

I'm getting a '[ytdl-sub] Validation error in mvg.download: should be of type object.' error after adding a series of new subscriptions to a subscriptions.yaml file that was already working.

I assume there must be a problem with one of the subscriptions I added, there does not appear to be any issue with the YAML file.

The issue/bug is of course I have absolutely no way of knowing what the issue is.

When reaching a validation error, the program needs to output as much data as possible, to give context, otherwise it's impossible to know where to start.

olinorwell commented 1 year ago

I managed to solve the issue, one of my subscriptions was incorrectly formed.

Where I slipped up was that 'mvg' was the name of one of my subscriptions, but.... I have 50+, so it didn't jump out at me.

I was missing a colon symbol between the 'url' and the URL itself.

So, 100% my fault. But it would help massively, and I think help especially new users, if it could give a more descriptive error report.

E.g.

"Your subscription 'mvg' is incorrectly formatted, check the file for any obvious syntax errors. See line: XYZ in file: subscriptions.yaml".

For me "should be of type object" didn't immediately turn into "you're missing a colon" in my head.

jmbannon commented 1 year ago

Validation error in mvg.download pointed you to mvg at least. But yeah I agree the error messages could be better. I'll look into adding line numbers and improving the object error message.

Behind the scenes it's expecting a certain type. In that instance, it expects a python dictionary (which is called object to users), but got a string from your missing colon. object is too vague to your point, I'll try to think of a better way to phrase this