Skip to content

[BUG][UI]: Metrics top performers panel incorrect display of zero values, timestamps, and unexecuted entity success ratesย #3793

@shoummu1

Description

@shoummu1

๐Ÿž Bug Summary

Five related bugs found in the top performers metrics panel, discovered during investigation of #3580:

  1. build_top_performers() loses 0.0 metric values โ€” metrics_common.py uses falsy checks (if result.success_rate) which coerce a genuine 0.0 success rate (100% failure) or 0.0 avg response time to None, losing the distinction between "no data" and an actual zero value.

  2. Dead != 'N/A' guard in template โ€” metrics_top_performers_partial.html checks avg_response != 'N/A', but avgResponseTime is Optional[float] and can only be None or a float โ€” never the string 'N/A'. The branch is unreachable.

  3. Dead != 'Never' guard in template โ€” similarly, the template checks last_exec != 'Never', but lastExecution from jsonable_encoder is either None or an ISO datetime string, never the string 'Never'. The branch is unreachable.

  4. Raw ISO datetime display in "Last Used" column โ€” the template renders {{ last_exec }} verbatim, producing unreadable output like 2024-01-15T10:30:00.000000 in the UI instead of a human-friendly format like 2024-01-15 10:30.

  5. successRate: None displays as 0.0% with a red error badge โ€” the or 0 fallback collapses None (no executions yet) into 0, making a tool with no data look like it has a 100% failure rate. Should display "N/A" with no badge, matching the avgResponseTime treatment.


๐Ÿงฉ Affected Component

  • mcpgateway - UI (admin panel)
  • mcpgateway - API

๐Ÿ” Steps to Reproduce

  1. Navigate to the Admin UI โ†’ Metrics tab โ†’ Top Performers panel
  2. Observe the "Last Used" column โ€” ISO timestamps are displayed raw (e.g. 2024-01-15T10:30:00.000000)
  3. Observe the "Success Rate" column for a tool that has never been executed โ€” it shows 0.0% with a red badge instead of N/A
  4. For bug 1: register a tool with 0% success rate โ€” the panel treats it as if it has no metrics at all

๐Ÿค” Expected Behavior

  1. A success_rate or avg_response_time of 0.0 should be preserved and displayed as 0.0, not treated as missing data.
  2. The != 'N/A' guard should be removed (dead code); None check is sufficient.
  3. The != 'Never' guard should be removed (dead code); falsy check on None is sufficient.
  4. The "Last Used" column should display a human-readable datetime like 2024-01-15 10:30 instead of a raw ISO string.
  5. The "Success Rate" column should display N/A (no badge) for entities with no execution data, not 0.0% with a red error badge.

๐Ÿ““ Logs / Error Output

No stack traces. These are silent display/logic bugs.


๐Ÿง  Environment Info

Key Value
Version or commit main
Runtime Python 3.11, Gunicorn
Platform / OS any
Container any

๐Ÿงฉ Additional Context (optional)

  • Affects mcpgateway/utils/metrics_common.py (build_top_performers function)
  • Affects mcpgateway/templates/metrics_top_performers_partial.html (avg response, success rate, last execution columns)

Metadata

Metadata

Assignees

Labels

SHOULDP2: Important but not vital; high-value items that are not crucial for the immediate releasebugSomething isn't workinguiUser Interface

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    โšก