Skip to content

Commit 0f22c2e

Browse files
Make struct name fixup work correctly for nested structs.
The code that did struct name fixup did not handle nested structs (e.g. struct-typed command fields, or struct-typed struct fields) correctly. In particular, it would not recursively call itself on the value for a field unless it was fixing up the field name. But there might be field names that don't need fixup that have values that are structs whose fields do need name fixup. The fix is to always call StructFieldsNameConverter on field values, and only condition the deletion of the "old name" from the value dictionary on whether the name is being fixed up.
1 parent bef3361 commit 0f22c2e

File tree

1 file changed

+3
-2
lines changed
  • examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter

1 file changed

+3
-2
lines changed

examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter/decoder.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,16 @@ def run(self, specs, value, cluster_name: str, typename: str, array: bool):
322322
provided_field_name = provided_field_name[0].lower(
323323
) + provided_field_name[1:]
324324

325-
if provided_field_name in value and provided_field_name != field_name:
325+
if provided_field_name in value:
326326
value[field_name] = self.run(
327327
specs,
328328
value[provided_field_name],
329329
cluster_name,
330330
field_type,
331331
field_array
332332
)
333-
del value[provided_field_name]
333+
if provided_field_name != field_name:
334+
del value[provided_field_name]
334335

335336
if specs.is_fabric_scoped(struct):
336337
if _FABRIC_INDEX_FIELD_CODE in value:

0 commit comments

Comments
 (0)