bluewave-labs / bluewave-labs/Checkmate

[Bug] Equal response times normalize to NaN

Open Beginner friendly
#3,813 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
10.8k
Forks
1.2k
Avg merge
1d 4h
Merged PRs (30d)
74

Description

### Describe the bug

When two or more checks all have the same response time, both normalization helpers return `NaN` for the chart value.

`NormalizeData` and `NormalizeDataUptimeDetails` calculate the p0 and p95 anchors and then divide by `max - min`. For a constant series those anchors are equal, so the range has zero width. When the result is serialized to JSON, `NaN` becomes `null`, leaving chart consumers without a numeric value.

The existing unit tests already characterize this as a known edge case, but intentionally expect the broken result.

### To reproduce

```ts
NormalizeData(
[{ responseTime: 50 }, { responseTime: 50 }],
10,
100
);
```

Both normalized `responseTime` values are `NaN`.

The same happens to `avgResponseTime` in `NormalizeDataUptimeDetails`.

### Expected behavior

Constant response-time series should produce a finite chart value while retaining the real value in `originalResponseTime` or `originalAvgResponseTime`.

Mapping a zero-width series to `rangeMin` is consistent with how the minimum anchor is normally mapped and keeps the bars visible without inventing relative variation.

Contributor guide

Open the contributing guide

Research direction

Locate the NormalizeData and NormalizeDataUptimeDetails entry points and read their existing unit tests, which already cover the constant-series edge case. Run those tests first, then make the zero-width case produce a finite rangeMin value while preserving the original response-time fields; update the expectations so both helpers are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.