Skip to content

bug: get_accessible_agents() called with wrong signature in monitoring router — 500 for non-admin fleet status #682

Closed

Description

@vybe

Summary

GET /api/ops/fleet/status throws a 500 TypeError for non-admin users because monitoring.py calls get_accessible_agents() with the old two-argument signature (email, agent_names). The function was refactored to accept a single User object, and every other call site was updated — only monitoring.py:104 was missed. Admin users are unaffected (they bypass the call).

Component

Backend / Monitoring Router (src/backend/routers/monitoring.py)

Priority

P2 — fleet status is broken for non-admin users; admins see it fine

Error

File "/app/routers/monitoring.py", line 104, in get_fleet_status
    accessible = get_accessible_agents(current_user.email, all_agent_names)
TypeError: get_accessible_agents() takes 1 positional argument but 2 were given

Location

  • File: src/backend/routers/monitoring.py
  • Line: 104
  • Function: get_fleet_status

Root Cause

get_accessible_agents was refactored in services/agent_service/helpers.py to accept (current_user: User) — it now fetches the agent list internally via list_all_agents_fast() rather than receiving it as a parameter. All call sites in agents.py, notifications.py, systems.py, fleet.py, and activities.py were updated to get_accessible_agents(current_user). The call in monitoring.py:104 was not updated.

Reproduction Steps

  1. Create a non-admin user account
  2. Log in as that user
  3. Call GET /api/ops/fleet/status (or open the Fleet / Dashboard page in the frontend)
  4. Observe 500 Internal Server Error with TypeError: get_accessible_agents() takes 1 positional argument but 2 were given

Admin users are unaffected — the branch at line ~101 (if current_user.role != "admin":) bypasses the call for admins.

Suggested Fix

In src/backend/routers/monitoring.py, replace the stale two-argument call with the current signature:

# REMOVE the separate agent list pre-fetch (monitoring.py already builds all_agents above)
# and replace lines ~101-107 with:

if current_user.role != "admin":
    accessible = get_accessible_agents(current_user)
    agent_names = [a["name"] for a in accessible]
else:
    agent_names = all_agent_names

get_accessible_agents(current_user) already calls list_all_agents_fast() internally, so the pre-fetched all_agent_names list can be dropped from the non-admin branch (admins still use all_agent_names directly).

Environment

  • Trinity version: ac8af7c (feat: per-agent token usage display)
  • Python: 3.11

Related

  • src/backend/services/agent_service/helpers.py — function definition (line 131)
  • src/backend/routers/agents.py — correct call pattern to follow (lines 143, 194, 256, 320)

Activity

  1. added
    status-in-progress
    and removed on May 7, 2026
  2. self-assigned this
    on May 7, 2026
  3. added
    status-in-dev
    and removed
    status-in-progress
    on May 7, 2026
  4. vybe commented on Jun 1, 2026

    @vybe
    ContributorAuthor

    Shipped in v0.6.0 (released via #998).

  5. removed
    status-in-dev
    on Jun 1, 2026
  6. added a commit that references this issue on Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority-p2type-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions