From 270e305ba7745f636ac1e00b52406648da174faa Mon Sep 17 00:00:00 2001 From: Bryan Oltman Date: Tue, 2 Dec 2025 12:09:30 -0500 Subject: [PATCH] fix(redis_client): throw exception instead of type error when redis response is not List (#3412) --- .../redis_client/lib/src/redis_client.dart | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/packages/redis_client/lib/src/redis_client.dart b/packages/redis_client/lib/src/redis_client.dart index 08f4313c..5e5c58d2 100644 --- a/packages/redis_client/lib/src/redis_client.dart +++ b/packages/redis_client/lib/src/redis_client.dart @@ -867,30 +867,33 @@ class RedisTimeSeries { RedisTimeSeriesAlign? align, RedisTimeSeriesAggregation? aggregation, }) async { - final results = - await _client.execute([ - 'TS.RANGE', - key, - from.value, - to.value, - if (filterByTimestamp != null) ...[ - 'FILTER_BY_TS', - ...filterByTimestamp.map((t) => t.value), - ], - if (filterByValue != null) ...[ - 'FILTER_BY_VALUE', - filterByValue.min, - filterByValue.max, - ], - if (count != null) ...['COUNT', count], - if (align != null) ...['ALIGN', align.value], - if (aggregation != null) ...[ - 'AGGREGATION', - aggregation.aggregator.toArgument(), - aggregation.bucketDuration.inMilliseconds, - ], - ]) - as List; + final results = await _client.execute([ + 'TS.RANGE', + key, + from.value, + to.value, + if (filterByTimestamp != null) ...[ + 'FILTER_BY_TS', + ...filterByTimestamp.map((t) => t.value), + ], + if (filterByValue != null) ...[ + 'FILTER_BY_VALUE', + filterByValue.min, + filterByValue.max, + ], + if (count != null) ...['COUNT', count], + if (align != null) ...['ALIGN', align.value], + if (aggregation != null) ...[ + 'AGGREGATION', + aggregation.aggregator.toArgument(), + aggregation.bucketDuration.inMilliseconds, + ], + ]); + + if (results is! List) { + throw RedisException(results.toString()); + } + return results.map((result) { final payload = result.payload as List; final timestamp = payload[0] as RespInteger;