Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
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

Fix handling of unmapped configuration options #185

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

ppacher
Copy link
Contributor

@ppacher ppacher commented Sep 5, 2022

This PR fixes a bug in the configuration system that prevents lazily registered config options to receive the current value stored in the configuration file.

Changes:

  1. When the configuration is loaded (replaceConfig) all unmapped/unused values from the configuration file are stored in a global unmappedValues map.
  2. When a configuration option is registered lazily, config.RegisterOption checks for unmapped values from the above map and immediately sets the value of the new option.
  3. If there was a matching unmapped value, the configuration key is removed from unmappedValues.

Copy link
Member

@dhaavi dhaavi left a comment

Choose a reason for hiding this comment

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

Tests seem to be failing.

Comment on lines 125 to 144
option.activeValue, vErr = validateValue(option, value)
if vErr != nil {
return fmt.Errorf("config: invalid value: %w", vErr)
}
Copy link
Member

Choose a reason for hiding this comment

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

Normal config loading just collects the validation errors from loaded config and reports them.
This would prevent the plugin from starting with an invalid config value, if it fails when failing to register the config option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after discussion: make sure we can return that error to the caller of config.Register() but not fail the registration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this requires an update to the plugin system to handle that case correctly

@ppacher
Copy link
Contributor Author

ppacher commented Jan 12, 2023

One thing that came to my mind, if an option is lazy-registered and the value is poped from the unmappedValues map, should we also trigger a config-change event?

@ppacher ppacher force-pushed the fix/unmapped-config-options branch from eb335ab to 3ae6368 Compare May 23, 2023 08:56
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.

2 participants