From d8b45d63b4e523ba821b3b0407c2a2ba471492f9 Mon Sep 17 00:00:00 2001 From: ecency Date: Mon, 13 Jul 2026 10:18:24 +0000 Subject: [PATCH 1/2] Treat empty Hive-Engine rewards response as no rewards, not an error An account with no Hive-Engine activity gets an empty object back from the rewards upstream. Both that and a non-object response threw into the catch, which logged an error and returned an empty array. The empty result was correct; the error log was not, and it fired on every such request. Return the empty array directly instead. Genuine failures still reach the catch and are still logged. Responses are unchanged. --- dotnet/EcencyApi/Handlers/WalletApi.Engine.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dotnet/EcencyApi/Handlers/WalletApi.Engine.cs b/dotnet/EcencyApi/Handlers/WalletApi.Engine.cs index 58bc46f4..4044ef9d 100644 --- a/dotnet/EcencyApi/Handlers/WalletApi.Engine.cs +++ b/dotnet/EcencyApi/Handlers/WalletApi.Engine.cs @@ -180,14 +180,14 @@ public static async Task FetchEngineRewards(string username) var response = await EngineRewardsRequest(username, new[] { new KeyValuePair("hive", "1") }); - if (response.Json is not JsonObject obj) - throw new Exception("No rewards data returned"); - - var rawValues = obj.Select(kv => kv.Value).ToList(); - if (rawValues.Count == 0) throw new Exception("No rewards data returned"); + // An account with no Hive-Engine activity is the common case, not a failure: + // the upstream answers with an empty object, which falls through the loop + // below to an empty result. Previously both that and a non-object response + // threw into the catch, logging an error on every such request. + if (response.Json is not JsonObject obj) return new JsonArray(); var filtered = new JsonArray(); - foreach (var raw in rawValues) + foreach (var raw in obj.Select(kv => kv.Value)) { var converted = HiveEngine.ConvertRewardsStatus(raw); var pendingToken = JsVal.AsNumber(converted["pendingToken"]); From 2e24882a9a900fe47a67185ef518fdd063f7dbe1 Mon Sep 17 00:00:00 2001 From: ecency Date: Mon, 13 Jul 2026 10:32:08 +0000 Subject: [PATCH 2/2] Keep logging non-object rewards payloads A non-object body means the rewards upstream is degraded (unparseable body, or valid JSON that is not an object), which is worth a log line. Only the empty object - the normal answer for an account with no Hive-Engine activity - is silent now. --- dotnet/EcencyApi/Handlers/WalletApi.Engine.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dotnet/EcencyApi/Handlers/WalletApi.Engine.cs b/dotnet/EcencyApi/Handlers/WalletApi.Engine.cs index 4044ef9d..d8e53f36 100644 --- a/dotnet/EcencyApi/Handlers/WalletApi.Engine.cs +++ b/dotnet/EcencyApi/Handlers/WalletApi.Engine.cs @@ -180,12 +180,15 @@ public static async Task FetchEngineRewards(string username) var response = await EngineRewardsRequest(username, new[] { new KeyValuePair("hive", "1") }); - // An account with no Hive-Engine activity is the common case, not a failure: - // the upstream answers with an empty object, which falls through the loop - // below to an empty result. Previously both that and a non-object response - // threw into the catch, logging an error on every such request. - if (response.Json is not JsonObject obj) return new JsonArray(); - + // A non-object body (unparseable, or valid JSON that isn't an object) means a + // degraded upstream: keep throwing so the catch below logs it. + if (response.Json is not JsonObject obj) + throw new Exception("Unexpected rewards payload"); + + // An empty object is NOT a failure — it is what the upstream returns for an + // account with no Hive-Engine activity, which is the common case. It falls + // through the loop below to the same empty result the catch used to produce, + // minus an error log on every such request. var filtered = new JsonArray(); foreach (var raw in obj.Select(kv => kv.Value)) {