Skip to content

Fix settings_hash clobbering nested template values with flat globals#38

Merged
marcosgz merged 2 commits into
mainfrom
fix/settings-flat-vs-nested-clobbering
Apr 29, 2026
Merged

Fix settings_hash clobbering nested template values with flat globals#38
marcosgz merged 2 commits into
mainfrom
fix/settings-flat-vs-nested-clobbering

Conversation

@marcosgz

@marcosgz marcosgz commented Apr 29, 2026

Copy link
Copy Markdown
Owner

When the cluster (global) settings are authored in the flat form (e.g. top-level number_of_shards: 1) and a per-index template is authored in the nested form (under index:), the simplified-key promotion in settings_hash ran AFTER the deep_merge and used merge!(key => value), which overwrote any value already present under values[:index] with the flat global value. Net effect: index.number_of_shards: 8 from the template was clobbered by number_of_shards: 1 from the cluster.

The fix normalizes each side (flat -> nested under :index) BEFORE deep_merge, so deep_merge's standard local-wins semantics apply and the per-index template's explicit value wins as expected.

INDEX_SIMPLIFIED_SETTINGS moved to Esse::IndexSetting and kept as a backwards-compatible alias on Esse::Index::ClassMethods.

Bump to 0.4.1.

When the cluster (global) settings are authored in the flat form (e.g.
top-level number_of_shards: 1) and a per-index template is authored in
the nested form (under index:), the simplified-key promotion in
settings_hash ran AFTER the deep_merge and used merge!(key => value),
which overwrote any value already present under values[:index] with
the flat global value. Net effect: index.number_of_shards: 8 from the
template was clobbered by number_of_shards: 1 from the cluster.

The fix normalizes each side (flat -> nested under :index) BEFORE
deep_merge, so deep_merge's standard local-wins semantics apply and
the per-index template's explicit value wins as expected.

INDEX_SIMPLIFIED_SETTINGS moved to Esse::IndexSetting and kept as a
backwards-compatible alias on Esse::Index::ClassMethods.

Bump to 0.4.1.
IndexSetting#body is part of the public surface and prior tests
documented it returning the raw deep_merge of globals over local
without normalization. The previous fix accidentally normalized in
body and broke those expectations.

Move the per-side normalization fully into Index::ClassMethods.settings_hash
by exposing IndexSetting#globals so settings_hash can normalize each
side independently before merging. Body keeps the original behavior.
@marcosgz
marcosgz merged commit 426251b into main Apr 29, 2026
28 checks passed
@marcosgz
marcosgz deleted the fix/settings-flat-vs-nested-clobbering branch April 29, 2026 20:34
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