From b359e21a5448c93d64dc1a5efdf6fce9c49a6b73 Mon Sep 17 00:00:00 2001 From: cwasicki <126617870+cwasicki@users.noreply.github.com> Date: Thu, 18 Dec 2025 01:43:15 +0100 Subject: [PATCH] Remove invalid HasField check on proto3 scalar metric value Scalar fields do not have HasField check in proto3. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com> --- RELEASE_NOTES.md | 2 +- src/frequenz/client/reporting/_types.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 17f924e..0ef6e64 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -14,4 +14,4 @@ ## Bug Fixes -* Fix default value of formula-aggregated metrics when no data was sent. +* Remove invalid HasField check on scalar which can cause failure retrieving formula-aggregated metrics. diff --git a/src/frequenz/client/reporting/_types.py b/src/frequenz/client/reporting/_types.py index d8632ff..06db377 100644 --- a/src/frequenz/client/reporting/_types.py +++ b/src/frequenz/client/reporting/_types.py @@ -190,7 +190,7 @@ def sample(self) -> MetricSample: metric = Metric(config.metric).name # Ignoring this verification results in # values of zero if the field is not set. - if sample.HasField("sample") and sample.sample.HasField("value"): + if sample.HasField("sample"): value = sample.sample.value else: value = math.nan