#4057·opencost

allocation returns negative `minutes` (end earlier than start) when the window is shorter than the resolution and the pod has no samples in it

Author: alishams23Created Sep 19, 2026Updated Sep 19, 2026

Describe the bug

When querying /allocation with a very short window (76 seconds) aggregated by pod and filtered to a single pod, the response contains an allocation whose end is earlier than its start, so minutes is negative. All costs and usage values in the allocation are 0.

To reproduce

GET /allocation?window=2026-09-19T05:44:57Z,2026-09-19T05:46:13Z&aggregate=pod&filter=pod:"neo4j-demo-566bbcc4d8-5jsm2"

Actual behavior

Trimmed response:

json
{
  "code": 200,
  "data": [{
    "neo4j-demo-566bbcc4d8-5jsm2": {
      "name": "neo4j-demo-566bbcc4d8-5jsm2",
      "properties": {
        "cluster": "default-cluster",
        "container": "neo4j-demo",
        "namespace": "demo",
        "pod": "neo4j-demo-566bbcc4d8-5jsm2"
      },
      "window": { "start": "2026-09-19T05:44:57Z", "end": "2026-09-19T05:46:13Z" },
      "start": "2026-09-19T05:44:57Z",
      "end": "2026-09-19T05:42:30Z",
      "minutes": -2.45,
      "cpuCoreHours": 0,
      "cpuCost": 0,
      "ramByteHours": 0,
      "ramCost": 0,
      "totalCost": 0,
      "rawAllocationOnly": { "cpuCoreUsageMax": 0.011054655380894975, "ramByteUsageMax": 0 }
    }
  }]
}
  • start equals the window start (05:44:57Z, not aligned to a minute).
  • end (05:42:30Z) is about 2.5 minutes before the window start, so minutes = (end - start) / 60 = -2.45.

Expected behavior

The allocation should never have end < start or negative minutes. If the pod has no samples inside the requested window, I would expect it to be omitted or returned with minutes: 0, not a reversed interval.