Skip to content

fix: gracefully handle missing config file with defaults#30

Open
brutusworker-arch wants to merge 1 commit intoApexOpsStudio:mainfrom
brutusworker-arch:fix/issue-2
Open

fix: gracefully handle missing config file with defaults#30
brutusworker-arch wants to merge 1 commit intoApexOpsStudio:mainfrom
brutusworker-arch:fix/issue-2

Conversation

@brutusworker-arch
Copy link

Summary

  • Fix crash (FileNotFoundError) when ~/.config/task-cli/config.yaml is missing
  • load_config() now creates the config directory and writes a sensible default config file when none exists

Changes

  • Added DEFAULT_CONFIG constant with default YAML configuration
  • Added get_config_path() helper for testability
  • Modified load_config() to check for config file existence before opening, creating defaults if missing
  • Added two tests: one for missing config (verifies default creation) and one for existing config (verifies it reads correctly)

Testing

  1. Delete config: rm -f ~/.config/task-cli/config.yaml
  2. Run: python task.py list — should work without crash
  3. Verify default config created: cat ~/.config/task-cli/config.yaml
  4. Run tests: python -m pytest test_task.py -v

Closes #2


Closes #2

Built by brutusworker-arch

@brutusworker-arch brutusworker-arch marked this pull request as ready for review March 20, 2026 12:34
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.

Fix: Crash when config file missing

1 participant