fix: prevent Config DEFAULTS mutation through deep_merge

Freeze inner hashes in DEFAULTS and rewrite deep_merge to build fresh
hashes with {}.merge for uncopied inner maps. Previously, inner hashes
shared objects with the frozen-looking DEFAULTS, so mutating a loaded
config silently poisoned all later loads.
This commit is contained in:
2026-06-25 22:06:49 +02:00
parent 263e794669
commit d7f9813484
2 changed files with 32 additions and 9 deletions
+8
View File
@@ -27,6 +27,14 @@ class ConfigTest < Minitest::Test
assert_equal "0.0.0.0", Volumen::Config.load(path: MISSING).host
end
def test_does_not_mutate_default_inner_hashes
config = Volumen::Config.load(path: MISSING)
config.site["title"] = "MUTATED"
fresh = Volumen::Config.load(path: MISSING)
assert_equal "My Blog", fresh.site["title"],
"mutating a loaded config must not poison DEFAULTS for later loads"
end
def test_loads_and_merges_file
Dir.mktmpdir do |dir|
path = File.join(dir, "config.toml")