Fix: Handle missing config file gracefully (#2)#55
Open
xyaz1313 wants to merge 1 commit intoApexOpsStudio:mainfrom
Open
Fix: Handle missing config file gracefully (#2)#55xyaz1313 wants to merge 1 commit intoApexOpsStudio:mainfrom
xyaz1313 wants to merge 1 commit intoApexOpsStudio:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for #2: Crash when config file missing
Problem
The app crashed with a
FileNotFoundErrorwhen~/.config/task-cli/config.yamldid not exist.Solution
load_config()now checks if the config file exists before trying to read itDEFAULT_CONFIGconstant with sensible defaults matchingconfig.yaml.exampleload_config()intomain()so config is loaded on every commandTesting
Added 3 new test cases:
test_load_config_creates_default_when_missing— verifies default config creationtest_load_config_reads_existing— verifies existing config is read correctlytest_default_config_is_valid_yaml— validates the default config contentAll 5 tests pass:
Fixes #2