The GET .../balances/:balance_id/history?date= endpoint returns error 0141 - No Balance Data at Date when querying a balance at a timestamp within the same second it was created.
Root cause: In components/transaction/internal/services/query/get-balance-at-timestamp.go:63, the comparison currentBalance.CreatedAt.After(timestamp) uses the database's sub-second precision (created_at = 23:15:15.500Z) against the API's second-precision parsed input (timestamp = 23:15:15.000Z). When the balance was created in the same second as the query timestamp but with a higher fractional component, the check incorrectly concludes the balance didn't exist yet.
Reproduction: Create a balance and immediately query its history at time.Now() truncated to seconds — the request intermittently fails depending on sub-second timing.
Suggested fix: Truncate both sides of the comparison to second precision, matching the API's input granularity:
if currentBalance.CreatedAt.Truncate(time.Second).After(timestamp.Truncate(time.Second)) {
The same pattern should be checked in GetAccountBalancesAtTimestamp if it has an equivalent comparison.
The GET .../balances/:balance_id/history?date= endpoint returns error 0141 - No Balance Data at Date when querying a balance at a timestamp within the same second it was created.
Root cause: In
components/transaction/internal/services/query/get-balance-at-timestamp.go:63, the comparisoncurrentBalance.CreatedAt.After(timestamp)uses the database's sub-second precision (created_at = 23:15:15.500Z) against the API's second-precision parsed input (timestamp = 23:15:15.000Z). When the balance was created in the same second as the query timestamp but with a higher fractional component, the check incorrectly concludes the balance didn't exist yet.Reproduction: Create a balance and immediately query its history at
time.Now()truncated to seconds — the request intermittently fails depending on sub-second timing.Suggested fix: Truncate both sides of the comparison to second precision, matching the API's input granularity:
The same pattern should be checked in
GetAccountBalancesAtTimestampif it has an equivalent comparison.