Skip to content

fix(dashboard-api): guard null throughput values in agents metrics html - #6341

Closed
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/agents-metrics-null-throughput
Closed

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/agents-metrics-null-throughput

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

In ods/extensions/services/dashboard-api/routers/agents.py, get_agent_metrics_html formats throughput values into the HTML fragment using f"{tp.get('current', 0):.1f}" and f"{tp.get('average', 0):.1f}". When telemetry feeds report uninitialized or null metrics (i.e. {"current": None, "average": None}), dict.get returns None instead of the fallback 0. Passing None to the :.1f format specifier immediately raises an unhandled TypeError: unsupported format string passed to NoneType.__format__, causing HTTP 500 errors on dashboard monitoring requests.

This change surgically applies float(tp.get('current') or 0) and float(tp.get('average') or 0) prior to formatting, cleanly defaulting None or empty throughput values to 0.0 without altering existing card styling or HTML structure.

Validation

  • Baseline reproduction: Calling get_agent_metrics_html with throughput: {"current": None, "average": None} raised TypeError: unsupported format string passed to NoneType.__format__.
  • Post-fix behavior: get_agent_metrics_html renders 0.0 tokens/sec without exception and returns HTTP 200.
  • Telemetry: Agents dashboard suites: 2 passed. New-test Ruff, ShellCheck, and diff checks pass; new regressions wired into Linux CI.

Overlap check

Recent PRs #6340 (pre-download option validation), #6337 (migrate-config environment diff), and #4270 (timestamp null-guard in agents metrics) address separate paths. This PR isolates throughput formatting in routers/agents.py without conflicting with adjacent dashboard features.

Risk / AI disclosure

AI-assisted investigation, implementation and CLI regressions. This strengthens an API validation check, not runtime admission. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.

Follow-up integration evidence

Composed with #6340 at 3df0a85 without conflicts. Production and test diffs passed together; agents and dashboard checks remain intact.
Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.

@Lightheartdevs

Copy link
Copy Markdown
Collaborator

Thanks for this contribution. public-beta was promoted into main on 2026-09-24 and no longer receives changes, so we're closing pull requests that target it. This isn't a judgment on the change itself. If it's still needed, please rebase onto main and open a focused PR. See #7253 for details and the contribution policy.

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