Fix settings_hash clobbering nested template values with flat globals#38
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.