Skip to content

fix: handle missing config file in load_config() - #126

Open
sirEven wants to merge 1 commit into
ApexOpsStudio:mainfrom
sirEven:fix/2-crash-when-config-file-missing
Open

fix: handle missing config file in load_config()#126
sirEven wants to merge 1 commit into
ApexOpsStudio:mainfrom
sirEven:fix/2-crash-when-config-file-missing

Conversation

@sirEven

@sirEven sirEven commented Jul 27, 2026

Copy link
Copy Markdown

Summary

Fixes #2

load_config() crashed with FileNotFoundError when ~/.config/task-cli/config.yaml was missing.

Changes

  • task.py: Added existence check in load_config() — returns a sensible default config string when the file is missing instead of crashing
  • test_config_missing.py: Added tests verifying the fix:
    • test_load_config_missing_file_returns_default: ensures no crash when config is absent
    • test_load_config_existing_file: ensures normal file reading still works

Root Cause

load_config() called open(config_path) without checking if the file exists, raising an unhandled FileNotFoundError.

Fix

Return a default configuration when the config file is missing, matching the format in config.yaml.example.

All 4 tests pass with no regressions.

load_config() now returns a default configuration instead of crashing
with FileNotFoundError when ~/.config/task-cli/config.yaml is missing.

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