config icon indicating copy to clipboard operation
config copied to clipboard

Option to Raise Error for Missing extra_sources Files

Open nna774 opened this issue 5 months ago • 4 comments

Thank you for implementing config.extra_sources in PR #366 ! I personally had a monkey patch in place to achieve similar functionality, and this new feature allowed me to remove it entirely, which is fantastic.

Currently, if a file specified in config.extra_sources does not exist, it is silently skipped. For example, the following code:

Config.setup do |config|
  config.extra_sources = ['does_not_exists.yml']
end

will not raise an error. This behavior appears to stem from the implementation around https://github.com/rubyconfig/config/blob/5e192a5ede17f90f972131f976ea69f3473c8c92/lib/config/sources/yaml_source.rb#L17

Expected Behavior / Feature Request: I propose adding an option to make Config raise an error (e.g., FileNotFoundError or a custom Config::Error) when a file listed in config.extra_sources does not exist.

The current silent failure can make it difficult to identify misconfigurations or typos in file paths. Explicitly raising an error would provide immediate feedback, aiding in debugging and ensuring that all intended configuration sources are loaded.

Thanks!

nna774 avatar Jul 31 '25 05:07 nna774