From 43330a9d986275775f4546412c0ba9047cf3f147 Mon Sep 17 00:00:00 2001 From: Daniel Zullo Date: Fri, 23 Aug 2024 15:23:55 +0200 Subject: [PATCH] Fix list gridpool orders Log the error if a grid pool order detail cannot be converted from the protobuf message to the OrderDetail object. But continue processing the other order details. Signed-off-by: Daniel Zullo --- RELEASE_NOTES.md | 14 +------------- .../client/electricity_trading/_client.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 40e493f..1745229 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,17 +1,5 @@ # Frequenz Electricity Trading API Client Release Notes -## Summary - - - -## Upgrading - - - -## New Features - - - ## Bug Fixes - +- Fixed list gridpool orders to log an error when an order conversion from protobuf failed and continuing to process other orders. diff --git a/src/frequenz/client/electricity_trading/_client.py b/src/frequenz/client/electricity_trading/_client.py index 509bffb..97f001f 100644 --- a/src/frequenz/client/electricity_trading/_client.py +++ b/src/frequenz/client/electricity_trading/_client.py @@ -639,10 +639,17 @@ async def list_gridpool_orders( # pylint: disable=too-many-arguments ), ) - return [ - OrderDetail.from_pb(order_detail) - for order_detail in response.order_details - ] + orders: list[OrderDetail] = [] + for order_detail in response.order_details: + try: + orders.append(OrderDetail.from_pb(order_detail)) + except InvalidOperation: + _logger.error( + "Failed to convert order details for order: %s", + str(order_detail).replace("\n", ""), + ) + + return orders except grpc.RpcError as e: _logger.exception("Error occurred while listing gridpool orders: %s", e) raise e