-
Notifications
You must be signed in to change notification settings - Fork 2
Fix configuration loading precedence and add missing environment variables #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: GrantBirki <23362539+GrantBirki@users.noreply.github.com>
…ables Co-authored-by: GrantBirki <23362539+GrantBirki@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Investigation of global configuration loading improvements, fixing precedence, adding missing environment mappings, boolean handling, and logging enhancements.
- Reordered config precedence to defaults → file → environment → programmatic
- Introduced missing HOOKS_… env var mappings with proper type conversion
- Added INFO-level override logging and enhanced error messages during config file load
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/hooks/core/config_loader.rb | Updated ConfigLoader.load to track and log override sources, fixed merge order, added env mappings and boolean conversion, improved error logging |
| .bundle/config | Adjusted bundler paths for CI environment |
Comments suppressed due to low confidence (2)
lib/hooks/core/config_loader.rb:156
- Add unit tests to verify the boolean conversion logic for environment variables, covering values like
true,1,yes,on, and invalid inputs to ensure correct behavior.
env_config[config_key] = %w[true 1 yes on].include?(value.downcase)
.bundle/config:3
- [nitpick] This introduces an absolute path in
.bundle/configwhich may not be portable. Consider removing.bundle/configfrom version control or switching to a relative path to avoid environment-specific settings.
BUNDLE_PATH: "/home/runner/work/hooks/hooks/vendor/bundle"
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot tests now fail when trying to use the project's global logger: |
…void dependency on uninitialized logger Co-authored-by: GrantBirki <23362539+GrantBirki@users.noreply.github.com>
Fixed the logger usage issue. The problem was that |
This PR fixes critical issues with configuration loading in the Hooks framework where the precedence order was incorrect and several environment variables were missing.
Issues Fixed
1. Incorrect Configuration Precedence
The configuration loading order was backwards - environment variables were overriding programmatic configuration, which contradicted the documented behavior in
docs/design.md.Before:
After:
2. Missing Environment Variable Support
Several configuration options defined in
GLOBAL_CONFIG_SCHEMAhad no correspondingHOOKS_*environment variables:HOOKS_USE_CATCHALL_ROUTEHOOKS_SYMBOLIZE_PAYLOADHOOKS_NORMALIZE_HEADERSHOOKS_LIFECYCLE_PLUGIN_DIRHOOKS_INSTRUMENTS_PLUGIN_DIRHOOKS_HANDLER_DIR(for backward compatibility)3. No Override Logging
There was no visibility into when configuration values were being overridden, making debugging difficult.
4. Poor Error Handling
Configuration file loading failures were silently ignored with no meaningful error messages.
Changes Made
Configuration Precedence Fix
Updated
ConfigLoader.load()to follow the correct precedence order:Added Missing Environment Variables
All
GLOBAL_CONFIG_SCHEMAvalues now have corresponding environment variable support with proper type conversion:Override Logging
Added informative logging when configuration overrides occur:
Improved Error Handling
Enhanced error messages for configuration loading failures:
Testing
Impact
This fix ensures that:
Fixes #23.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.