Skip to content

Check config files for bad settings, and explain unreadable input files - #142

Merged
zfleeman merged 2 commits into
mainfrom
zf/config-validation
Nov 6, 2026
Merged

zfleeman merged 2 commits into
mainfrom
zf/config-validation

Conversation

@zfleeman

@zfleeman zfleeman commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Closes #141.

Config files

A config file's values become argparse defaults, and argparse never checks defaults against choices or flags unknown keys. So {"codec": "libvpx-vp9"} (the README's own example) ran raw libvpx without the vp9 speed settings, and a typo like {"target-filesize": 20} crashed with a TypeError traceback.

_check_config() in arguments.py now checks each config file as it loads (the default one, --config, and any file a config points to) and stops with parser.error():

  • Unknown key: config.json has an unknown setting 'target-filesize'. Did you mean 'target_filesize'?
  • Bad choice: config.json: argument -c/--codec: invalid choice: 'libvpx-vp9' (choose from 'x264', ...)

The config key is still allowed. The message shows the file's full path, so it's clear which file to fix when the default config is the culprit.

Unreadable input files

ff4d nope.mp4 used to end in a raw ffmpeg._run.Error: ffprobe error traceback. main() now catches ffmpeg.Error from TwoPass(path) and logs ffprobe's last stderr line, which names the file and the problem:

  • /clips/nope.mp4: No such file or directory
  • /clips/notes.mp4: Invalid data found when processing input
  • /clips: Is a directory

README

  • JSON example uses "codec": "vp9".
  • Installation says Python >= 3.10, matching pyproject.toml.
  • Fixed the --no-config example (no---config).

Tests

  • test_arguments.py: unknown key, invalid codec, and a bad value in a nested config (the message names the inner file). Replaced the test that expected unknown keys to pass through, and changed a "vp9-speed" codec that's no longer accepted to "vp9".
  • test_main.py: an ffprobe error exits 1 with the stderr reason, or a fallback message when stderr is empty.

@zfleeman
zfleeman merged commit 9bf2f0c into main Nov 6, 2026
6 checks passed
@zfleeman
zfleeman deleted the zf/config-validation branch November 6, 2026 01:46
@zfleeman zfleeman mentioned this pull request Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config files skip codec checks and crash on unknown keys

1 participant