Stop a config.yaml typo from wiping the config (#6) #24

Merged
eric merged 1 commit from eric/fix-6-config-parse-error into master 2026-10-12 15:46:23 -05:00 AGit
Owner

Closes #6

Problem: if config.yaml didn't parse, the app overwrote it with defaults. You'd lose the database location, player and theme, and get first-time setup again. The app could also write a config it couldn't read back: values were written without quoting, so a Windows path, or a player command with # or : , broke parsing on the next start.

Fix:

  • load_config (replacing read_config) returns an error when the file can't be read or parsed, and never touches the file. main prints the error and exits before the full-screen UI starts:
    Error: Could not parse …/config.yaml: found unexpected end of stream at line 5 column 1, while scanning a quoted scalar at line 1 column 14
    Fix or remove the file and start movies again. It has not been changed.
    
  • Every string value is written through serde_yaml, so it's quoted only when needed. Ordinary values look the same as before. One small visible change: db_location and log_file are no longer always wrapped in double quotes.
  • A missing config is still created with defaults, as before.

I chose exiting over "use defaults for this session only", because a session with defaults has no database location. It would go into first-time setup, which saves the config and overwrites your file anyway.

Testing:

  • Updated the invalid-YAML test: it now checks for an error and that the file is unchanged. New test saves and reloads a Windows path, a player command with #1: in it, and the word null.
  • Ran the real binary against a broken config: it printed the message above, exited with code 1, and the file was byte-for-byte unchanged. A fresh start still writes the same default config as before.
  • Full suite: 207 passed, 3 failed, all in buffer_performance_tests (timing limits, #12).

🤖 Generated with Claude Code

https://claude.ai/code/session_01E2XefpQijvBcJBfgzuaoWA

Closes #6 **Problem:** if `config.yaml` didn't parse, the app overwrote it with defaults. You'd lose the database location, player and theme, and get first-time setup again. The app could also write a config it couldn't read back: values were written without quoting, so a Windows path, or a player command with `#` or `: `, broke parsing on the next start. **Fix:** - `load_config` (replacing `read_config`) returns an error when the file can't be read or parsed, and never touches the file. `main` prints the error and exits before the full-screen UI starts: ``` Error: Could not parse …/config.yaml: found unexpected end of stream at line 5 column 1, while scanning a quoted scalar at line 1 column 14 Fix or remove the file and start movies again. It has not been changed. ``` - Every string value is written through `serde_yaml`, so it's quoted only when needed. Ordinary values look the same as before. One small visible change: `db_location` and `log_file` are no longer always wrapped in double quotes. - A missing config is still created with defaults, as before. I chose exiting over "use defaults for this session only", because a session with defaults has no database location. It would go into first-time setup, which saves the config and overwrites your file anyway. **Testing:** - Updated the invalid-YAML test: it now checks for an error and that the file is unchanged. New test saves and reloads a Windows path, a player command with `#1:` in it, and the word `null`. - Ran the real binary against a broken config: it printed the message above, exited with code 1, and the file was byte-for-byte unchanged. A fresh start still writes the same default config as before. - Full suite: 207 passed, 3 failed, all in `buffer_performance_tests` (timing limits, #12). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01E2XefpQijvBcJBfgzuaoWA
read_config replaced a config.yaml it couldn't parse with the defaults,
losing db_location, the player and the theme, and sending the user
back through first-time setup.

load_config now returns an error for a file it can't read or parse and
leaves the file alone; main prints the error and exits before the
terminal is set up. The read_config fallback is removed.

generate_yaml_with_comments now writes every string value through
serde_yaml, so values with backslashes (Windows paths), "#", ": " or
words like "null" are quoted and read back correctly.

Closes #6

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2XefpQijvBcJBfgzuaoWA
eric merged commit e441101846 into master 2026-10-12 15:46:23 -05:00
Sign in to join this conversation.
No reviewers
No labels
bug
chore
feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
spinach-dev/movies!24
No description provided.