Skip to content

Commit a483888

Browse files
committed
fix parent_keys in config_loader
1 parent e69fbae commit a483888

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

st2common/st2common/util/config_loader.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,26 @@ def _assign_dynamic_config_values(self, schema, config, parent_keys=None):
144144
is_dictionary = isinstance(config_item_value, dict)
145145
is_list = isinstance(config_item_value, list)
146146

147+
# pass a copy of parent_keys so the loop doesn't add sibling keys
148+
current_keys = parent_keys + [str(config_item_keys)]
149+
147150
# Inspect nested object properties
148151
if is_dictionary:
149-
parent_keys += [str(config_item_key)]
150152
property_schema = self._get_object_property_schema(
151153
schema_item,
152154
additional_properties_keys=config_item_value.keys(),
153155
)
154156
self._assign_dynamic_config_values(
155157
schema=property_schema,
156158
config=config[config_item_key],
157-
parent_keys=parent_keys,
159+
parent_keys=current_keys,
158160
)
159161
# Inspect nested list items
160162
elif is_list:
161-
parent_keys += [str(config_item_key)]
162163
self._assign_dynamic_config_values(
163164
schema=schema_item.get("items", {}),
164165
config=config[config_item_key],
165-
parent_keys=parent_keys,
166+
parent_keys=current_keys,
166167
)
167168
else:
168169
is_jinja_expression = jinja_utils.is_jinja_expression(
@@ -171,9 +172,7 @@ def _assign_dynamic_config_values(self, schema, config, parent_keys=None):
171172

172173
if is_jinja_expression:
173174
# Resolve / render the Jinja template expression
174-
full_config_item_key = ".".join(
175-
parent_keys + [str(config_item_key)]
176-
)
175+
full_config_item_key = ".".join(current_keys)
177176
value = self._get_datastore_value_for_expression(
178177
key=full_config_item_key,
179178
value=config_item_value,

0 commit comments

Comments
 (0)