Skip to content

fix(monitoring): report measured 0% uptime and 0 ms latency instead of null - #4699

Merged
vybe merged 1 commit into
Abilityai:devfrom
pcbeingused333:fix/4685-health-measured-zero
Nov 21, 2026
Merged

vybe merged 1 commit into
Abilityai:devfrom
pcbeingused333:fix/4685-health-measured-zero

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #4685

Description

GET /api/monitoring/agents/{name} built uptime_percent_24h and avg_latency_24h_ms with a truthiness test (if uptime else None). A measured 0.0 (an agent unreachable for the whole 24 h window, or a measured 0 ms latency) is falsy, so the response carried null, which consumers read as "never measured". Both fields now use is not None, so only a missing measurement is null.

Related Issue

Fixes #4685

Journey Impact

Journey Impact: none: only the agent health detail response changes, from null to 0.0 when 0 was measured

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Testing

  • I have tested this locally
  • New tests added (if applicable)
  • All existing tests pass

New tests/unit/test_4685_health_measured_zero.py (registered in tests/registry.json) calls the real handler against a real DB (same harness as #3950): an agent with only an unreachable aggregate check and a 0.0 ms network check must report 0.0 for both fields (fails on dev with None), and an agent whose only checks are outside the 24 h window still reports None for both. With the fix both pass, as do the 10 tests in test_3950_fleet_health_current.py.

Checklist

  • My code follows the project's style guidelines
  • I have updated the documentation (if applicable)
  • I have not committed any sensitive data (API keys, credentials, etc.)
  • My commits are signed off (git commit -s) — required for contributors outside the core team
  • I have added appropriate logging for new functionality

This PR was prepared with AI assistance (Claude Code); disclosed here as CONTRIBUTING asks.

🤖 Generated with Claude Code

…f null

The agent health detail handler used a truthiness test for the 24h
figures, so a measured 0.0 came back as null ("never measured"). Use
'is not None' so only a missing measurement is null.

Fixes Abilityai#4685

Signed-off-by: Alex Castillo <[email protected]>
@vybe

vybe commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

merge-train (2026-11-21): on this train. Validated at 2159fd67f: READY. The test drives the real handler against a real DB, and reverting to truthiness turns it red. The frontend renders 0 as "0%".

The same truthiness bug is still in perform_health_check (services/monitoring_service.py:858-859), which feeds POST /api/monitoring/agents/{name}/check and the GET handler's first-ever-check path. #4685 named only the router, so this PR is correct for its scope. Merged with the findings filed as #4702. You are welcome to take it.

Your CI runs were waiting for maintainer approval; they are approved and running now.

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge-train: batch validated on train/20261121-1212 (#4705)

@vybe
vybe merged commit 38084ec into Abilityai:dev Nov 21, 2026
28 of 29 checks passed
vybe added a commit to pcbeingused333/trinity that referenced this pull request Nov 22, 2026
… — mechanical, per the merge-train note on the PR

- tests/unit/test_4702_perform_health_check_zero.py: register the module under test with
  monkeypatch.setitem instead of a bare sys.modules write (lint_sys_modules.py: 0 -> 1 violation)
- docs/memory/learnings/: fragment for the truthiness-zero class (Abilityai#4685, Abilityai#4699, Abilityai#4702)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Eugene Vyborov <[email protected]>
vybe added a commit that referenced this pull request Nov 23, 2026
…orm_health_check (#4720)

* fix(monitoring): report measured 0% uptime and 0 ms latency from perform_health_check

perform_health_check built its 24h figures with a truthiness test, so a
measured 0.0 came back as None ("never measured") on POST
/api/monitoring/agents/{name}/check and the first-check path of the GET.
Use 'is not None', as #4699 did for the router's own builder.

Fixes #4702

Signed-off-by: Alex <[email protected]>

* merge-train: sys.modules lint fix + learnings fragment (#4702) — mechanical, per the merge-train note on the PR

- tests/unit/test_4702_perform_health_check_zero.py: register the module under test with
  monkeypatch.setitem instead of a bare sys.modules write (lint_sys_modules.py: 0 -> 1 violation)
- docs/memory/learnings/: fragment for the truthiness-zero class (#4685, #4699, #4702)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Eugene Vyborov <[email protected]>

---------

Signed-off-by: Alex <[email protected]>
Signed-off-by: Eugene Vyborov <[email protected]>
Co-authored-by: Eugene Vyborov <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants