Skip to content

bug(api): literal routes declared after a {param} route never run — the anonymous embed widget gets 401, plugin audit and SLM node conflicts 404 #18720

Closed

Description

@mrveiss

Verified on origin/main 0196c7c234 (umbrella #18717). Starlette matches in registration order; a {param} route registered earlier captures a later literal.

Literal (dead) Captured by Effect today
POST /api/chats/embed/message (api/chat_embed.py:172) POST /api/chats/{chat_id}/message (api/chat.py:1529); chat is registered before chat_embed (core_routers.py:164 vs :166), both at prefix "" the anonymous embed widget (autobot-frontend/src/embed/AutobotWidget.ts:186) hits the authenticated handler: 401 (GH#9047 broken). chat_embed_test.py mounts only the embed router, so it can't see this
GET /api/plugins/audit (plugin_manager.py:632) /api/plugins/{plugin_name} (:408) the capability-audit panel (usePlugins.ts:288) gets "plugin 'audit' not found"
SLM GET /api/nodes/a2a-cards (api/nodes.py:2839) GET /api/nodes/{node_id} (:532), same router 404 node-not-found
SLM GET /api/nodes/conflicts (api/services.py:778) the same, nodes_router is included first (main.py:652 vs :654) 404
GET /api/batch-jobs/status, GET /api/batch-jobs/chat-init (batch_jobs.py:766, :838) GET /api/batch-jobs/{job_id} (:210) the SLM batch health check (useAutobotApi.ts:1480) gets 404; these also have no auth (#18718)

Not affected: /batch-jobs/templates/ and /schedules/. The FE sends the trailing slash, which {job_id} ([^/]+) does not match.

Acceptance criteria

Activity

  1. mrveiss commented on Oct 17, 2026

    @mrveiss
    OwnerAuthor

    The external report's complete shadowing set (api-route-duplicates-groups.csv, type b) has 3 more that the verification pass didn't cover; include them, confirming each first:

    • B001 GET /api/vnc-proxy/{vnc_type}/status (api/vnc_proxy.py:500) shadowed by /api/vnc-proxy/{vnc_type}/{path:path} (:367); 2 backend callers.
    • B005 GET /api/permissions/memory/stats (api/permissions.py:495) shadowed by /api/permissions/memory/{project_path:path} (:366).
    • B006 GET /api/a2a/trust/{peer_id:path}/audit (api/a2a_trust.py:107) shadowed by /api/a2a/trust/{peer_id:path} (:86); a :path converter swallows the /audit suffix.
      That makes 9 distinct literals (B007/B008 are the same embed route, registered twice).
  2. mrveiss commented on Oct 18, 2026

    @mrveiss
    OwnerAuthor

    Closed by #18743 (train 31, merged as fb45ae4). The AC evidence, checked against origin/main fb45ae4:

    • AC2 ticked. repo_tests/shadowed_literal_routes_18720_test.py covers both apps:
      • test_no_literal_route_sits_behind_a_param_route is parametrised over the backend and the SLM. It reads the real registration order through autobot_shared/api_routing/route_order.py, and fails on unresolved routers rather than reading them as clean.
      • The planted controls are test_planted_param_before_literal_is_reported, test_planted_path_converter_swallows_a_suffix and test_a_param_route_behind_an_earlier_param_route_is_reported. Negatives cover param-first and other shapes.
    • AC3 ticked. The fix(slm): re-enrolling a decommissioned node logs EventType.STATE_CHANGE, a member that exists — every re-enroll was a 500 (#18712) #18713 merge is 2bb5944 (train 30), which is before train 31. On main, SLM api/nodes.py:532 @router.get("/a2a-cards") precedes :558 @router.get("/{node_id}").
    • AC1 left unticked, with the reason. _LITERALS in that test lists all 9 literals. That includes the 3 added in the comment above: vnc-proxy status, permissions memory stats and a2a trust audit. test_literal_is_the_route_the_app_picks asserts each one is answered by its own template under the full registration order. That order is rebuilt statically from source, not a live app. "Each fails on main" can't be checked from the merged code; showing it needs a run against the pre-fix tree, and I didn't do that. Reopen if that proof is required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions