Skip to content

fix: Gracefully handle missing config file#14

Open
V1ki wants to merge 1 commit intoApexOpsStudio:mainfrom
V1ki:fix/crash-missing-config
Open

fix: Gracefully handle missing config file#14
V1ki wants to merge 1 commit intoApexOpsStudio:mainfrom
V1ki:fix/crash-missing-config

Conversation

@V1ki
Copy link

@V1ki V1ki commented Feb 27, 2026

Summary

Fixes #2 — app no longer crashes with a bare FileNotFoundError when ~/.config/task-cli/config.yaml is absent.

Changes

  • task.py: load_config() now checks for the config file before opening it. If it's missing, it creates the directory tree and writes a sensible default config (mirrors config.yaml.example). A one-time informational message is printed to stderr.
  • test_task.py: Added three tests covering:
    • Default config is created when absent
    • Existing config is read without overwriting
    • No FileNotFoundError is raised (and correct message emitted)

Before / After

# Before
$ python task.py list
Traceback (most recent call last):
  ...
FileNotFoundError: [Errno 2] No such file or directory: '~/.config/task-cli/config.yaml'

# After
$ python task.py list
Created default config at /Users/user/.config/task-cli/config.yaml
No tasks yet!

All 5 tests pass.

- Create default config at ~/.config/task-cli/config.yaml if absent
- Print informative message to stderr on first run
- Add tests for missing config, existing config, and no-crash guarantee

Fixes ApexOpsStudio#2
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