Skip to content

Conversation

@neilhuang007
Copy link

  • Use default values when config options are missing instead of throwing
  • Regenerate config automatically when options are missing or malformed
  • Add TRUNCATE_EXISTING to prevent leftover data from corrupting config
  • Remove System.exit(1) on config parse errors to allow recovery

Fixes #115

- Use default values when config options are missing instead of throwing
- Regenerate config automatically when options are missing or malformed
- Add TRUNCATE_EXISTING to prevent leftover data from corrupting config
- Remove System.exit(1) on config parse errors to allow recovery

Fixes imthosea#115
Copilot AI review requested due to automatic review settings December 25, 2025 00:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make the application more robust by handling corrupted or malformed config files gracefully instead of crashing. The changes allow the application to recover from config errors by using default values and automatically regenerating the config file.

Key changes:

  • Removed System.exit(1) call when config loading fails, allowing the application to continue with default values
  • Added hasMissingOptions flag to track when config options are missing and trigger automatic regeneration
  • Added TRUNCATE_EXISTING flag when writing config to prevent leftover data from corrupting the file

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
ConfigLoadContext.java Added missing options tracking, removed fatal error exit, and changed missing option handling to log warnings instead of throwing exceptions
Config.java Updated config regeneration condition to include missing options case and added TRUNCATE_EXISTING flag to file write operation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +75 to 77
LOGGER.warn("Config option {} not found - using default value. Config will be regenerated.", name);
hasMissingOptions = true;
}
Copy link

Copilot AI Dec 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exceptions thrown in boolOrDefault (line 50) and intOrDefault (lines 62, 65) when config values are malformed are not handled. These exceptions will prevent the graceful recovery that this PR aims to provide. When a config value is malformed (e.g., "maybe" instead of "true"/"false", or "abc" instead of a number), the application will still crash instead of using the default value.

Copilot uses AI. Check for mistakes.
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