Skip to content

fix: handle missing config file gracefully (no more crash on first run)#35

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

fix: handle missing config file gracefully (no more crash on first run)#35
DrGalio wants to merge 1 commit intoApexOpsStudio:mainfrom
DrGalio:fix/missing-config-crash

Conversation

@DrGalio
Copy link

@DrGalio DrGalio commented Mar 26, 2026

Summary

Fixes the FileNotFoundError crash when ~/.config/task-cli/config.yaml is missing. The CLI now creates a sensible default config on first run.

Changes

  • task.py: load_config() now:
    • Creates ~/.config/task-cli/ directory if missing
    • Writes a default config.yaml if the file doesn't exist
    • Returns the default config content instead of crashing
  • test_task.py: Added 3 new tests:
    • test_load_config_creates_default_when_missing — verifies default config is created when file is absent
    • test_load_config_reads_existing_file — verifies existing files are read correctly
    • test_load_config_handles_missing_entire_config_dir — verifies full missing-directory scenario
  • .gitignore: Added Python cache exclusions

Acceptance Criteria

  • No crash when config file is missing
  • Creates sensible default config (matching config.yaml.example structure)
  • Tests added for missing config scenario
  • All 5 tests pass

Verification

# Tests pass
$ python3 -m pytest test_task.py -v
5 passed in 0.03s

# CLI works without config
$ HOME=/tmp/fake_home python3 task.py list
No tasks yet!  # ✓ No crash

@DrGalio DrGalio force-pushed the fix/missing-config-crash branch from 07361fb to af8ffc5 Compare March 26, 2026 08:28
@DrGalio DrGalio changed the title Fix: Crash when config file missing fix: handle missing config file gracefully (no more crash on first run) Mar 26, 2026
When ~/.config/task-cli/config.yaml doesn't exist, load_config() now
creates a default config file instead of crashing with FileNotFoundError.

Changes:
- load_config() creates default config if missing
- Wired load_config() into main() so config is loaded on startup
- Added tests for missing config and existing config scenarios

Fixes ApexOpsStudio#2
@DrGalio DrGalio force-pushed the fix/missing-config-crash branch from af8ffc5 to 8394f53 Compare March 26, 2026 14:04
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.

1 participant