| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
`electrical_component_from_proto` builds `CategorySpecificInfo.fields` with `MessageToDict`, which defaults to protobuf JSON `lowerCamelCase` keys. That contradicted the field's documented contract — "the keys are the protobuf field names" — for every multiword field: a grid connection point's `rated_fuse_current` was exposed as `ratedFuseCurrent`, so a forward-compatible caller reading the documented `fields["rated_fuse_current"]` off an unrecognized or mismatched component got a `KeyError`. Pass `preserving_proto_field_name=True` so the keys are the `snake_case` `.proto` field names, matching both the docstring and the typed attributes (e.g. `GridConnectionPoint.rated_fuse_current`). The recognized grid connection point strips its translated field from the leftover `fields`, so update that key from `"ratedFuseCurrent"` to `"rated_fuse_current"` too; otherwise the newly snake_cased key would leak back into `fields`. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
There was a problem hiding this comment.
🤖 Correct fix for a real contract violation.
I checked all five _leftover_info call sites: grid was the only one keyed on a multiword field, so "type", "primary" and "secondary" are unaffected by the flag and the single key update is complete.
CategorySpecificInfo doesn't exist at v0.4.0, so this fixes an unreleased feature and cmd:skip-release-notes is the right call.
Sorry, something went wrong.
* Mention that `metric_config_bounds` keys also store the raw `0` for unspecified metrics (frequenz-floss#224). * Merge the two `Microgrid` bullets, which described the same addition. * Describe the `ElectricalComponent` boolean accessors (frequenz-floss#237), the `CategorySpecificInfo` field (frequenz-floss#257, frequenz-floss#273) and the aggregated `metric_config_bounds` (frequenz-floss#268). * Add a compact list of the smaller supporting types from frequenz-floss#248 and frequenz-floss#249 (`Invalid{Latitude,Longitude,CountryCode}`, `InvalidLifetime` and their errors). Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Fill the gaps found in a pre-release sanity check of `RELEASE_NOTES.md`: * Replace the template placeholder with a real release summary, including release stats and the note that this is a huge release despite the patch version, realizing the new library design while keeping backwards compatibility, with the breaking cleanup to follow in v0.5.0. * Document two breaking changes to symbols released in v0.4.0 that were missing from Upgrading: `Bounds` raising on `NaN` endpoints (frequenz-floss#254) and `MetricConnection.name` no longer being optional (frequenz-floss#257). * Complete the `UNSPECIFIED`-as-`0` bullet with `metric_config_bounds` keys (frequenz-floss#224), merge the duplicated `Microgrid` bullets, and briefly cover the `ElectricalComponent` accessors, `CategorySpecificInfo` and the smaller `Invalid*` types from frequenz-floss#237, frequenz-floss#248, frequenz-floss#249, frequenz-floss#257, frequenz-floss#268 and frequenz-floss#273. * Add the `str()` exception message change (frequenz-floss#258) to Bug Fixes. The `PaginationInfo` breaking change from frequenz-floss#217 is documented separately in frequenz-floss#285, which adds `InvalidPaginationInfo` and `pagination_info_from_proto2`.
| Back | FazBrowse Home | New Git URL |
electrical_component_from_proto builds CategorySpecificInfo.fields with MessageToDict, which defaults to protobuf JSON lowerCamelCase keys. That contradicted the field's documented contract — "the keys are the protobuf field names" — for every multiword field: a grid connection point's rated_fuse_current was exposed as ratedFuseCurrent, so a forward-compatible caller reading the documented fields["rated_fuse_current"] off an unrecognized or mismatched component got a KeyError.
Pass preserving_proto_field_name=True so the keys are the snake_case .proto field names, matching both the docstring and the typed attributes (e.g. GridConnectionPoint.rated_fuse_current). The recognized grid connection point strips its translated field from the leftover fields, so update that key from "ratedFuseCurrent" to "rated_fuse_current" too; otherwise the newly snake_cased key would leak back into fields.