Skip to content

Fix: Handle missing config file gracefully (#2)#55

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

Fix: Handle missing config file gracefully (#2)#55
xyaz1313 wants to merge 1 commit intoApexOpsStudio:mainfrom
xyaz1313:fix/config-missing-crash

Conversation

@xyaz1313
Copy link
Copy Markdown

Fix for #2: Crash when config file missing

Problem

The app crashed with a FileNotFoundError when ~/.config/task-cli/config.yaml did not exist.

Solution

  • load_config() now checks if the config file exists before trying to read it
  • If missing, it creates the directory structure and writes a default config file
  • Added DEFAULT_CONFIG constant with sensible defaults matching config.yaml.example
  • Integrated load_config() into main() so config is loaded on every command

Testing

Added 3 new test cases:

  • test_load_config_creates_default_when_missing — verifies default config creation
  • test_load_config_reads_existing — verifies existing config is read correctly
  • test_default_config_is_valid_yaml — validates the default config content

All 5 tests pass:

test_task.py::test_validate_description PASSED
test_task.py::test_validate_task_id PASSED
test_task.py::test_load_config_creates_default_when_missing PASSED
test_task.py::test_load_config_reads_existing PASSED
test_task.py::test_default_config_is_valid_yaml PASSED

Fixes #2

The app previously crashed with a FileNotFoundError when
~/.config/task-cli/config.yaml did not exist.

Changes:
- load_config() now creates a default config file if missing
- Added DEFAULT_CONFIG constant with sensible defaults
- Integrated load_config() call into main()
- Added 3 test cases for the fix

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