@@ -77,7 +77,7 @@ def _convert_value(value: Any, type_hint: Any) -> Any:
7777def _dict_to_dataclass (data : Mapping [str , Any ], cls : type [_T ]) -> _T :
7878 """Recursively convert a mapping to a dataclass instance.
7979
80- For each key in ``data``:
80+ For each (normalized) key in ``data``:
8181 - If it matches a known dataclass field, the value is converted according
8282 to that field's type annotation (recursing for nested dataclasses).
8383 - Unknown keys are passed through as kwargs; classes decorated with
@@ -103,11 +103,15 @@ def _dict_to_dataclass(data: Mapping[str, Any], cls: type[_T]) -> _T:
103103 kwargs : dict [str , Any ] = {}
104104
105105 for key , value in data .items ():
106- if key in known_fields :
107- type_hint = hints .get (key )
108- kwargs [key ] = _convert_value (value , type_hint )
106+ # OpenTelemetry Configuration schema uses "/" to separate the feature from its
107+ # stability level (e.g. "detection/development"). Normalize to "_" so
108+ # the key matches valid Python dataclass field names.
109+ normalized_key = key .replace ("/" , "_" )
110+ if normalized_key in known_fields :
111+ type_hint = hints .get (normalized_key )
112+ kwargs [normalized_key ] = _convert_value (value , type_hint )
109113 else :
110114 # Unknown key — @_additional_properties decorator will capture it.
111- kwargs [key ] = value
115+ kwargs [normalized_key ] = value
112116
113117 return cls (** kwargs )
0 commit comments