The inspector's port shutdown toggle 404s on every port name with a slash, and a link-state response shadows state #1307

Closed
opened 2026-11-10 00:54:18 +00:00 by jaylouisw · 0 comments
Owner

Found while auditing that every state payload carries the same shape after #1304/#1305. It is unrelated to that
work and much worse.

1. The inspector's shutdown toggle does nothing on most of the catalogue

POST /api/topologies/:name/interfaces/:device/:port required exactly one path segment for the port
(parts.length === 6). But a port name is 1/1/1, Fa0/1, Gi0/0/2 — it contains slashes. So the URL the UI
builds splits into extra segments and the endpoint never matches. Measured against a live server:

POST /api/topologies/default/interfaces/d1/1/1/1
  -> 404 {"error":"unknown endpoint: /api/topologies/default/interfaces/d1/1/1/1"}
POST /api/topologies/default/interfaces/d1/1%2F1%2F1
  -> 404 {"error":"interface not found"}

The plain form falls through to the 404 at the bottom of the router; the encoded form reaches the handler but is
never decoded. So the ▲/▼ shutdown control in the inspector — rendered, wired, and inert — has never worked for
any device whose port names use slashes, which is most of the catalogue. Nothing caught it because every test
drives the engine directly, not the URL.

2. state appears twice in one response object

POST /api/topologies/:name/links/:id/state returns:

{ ok: true, linkId: parts[4], state: state, atMs, reconvergeAtMs, changed, convergence,
  state: fullState(topo) }

The link's own 'up'/'down' string and the whole topology under the same key. It currently works by luck:
JavaScript keeps the later key. Reorder those lines, or delete the second, and the entire UI stores state: "down" and blanks the board.

What must be true instead

  • a port name in a URL may be the rest of the path, and percent-encoded names must be decoded — both forms
    reaching the same port, and the port actually changing state;
  • the cable-state response names its string linkState, so state means one thing: the topology payload that
    every other endpoint returns;
  • a test asserts, over real HTTP, that a slash-named port toggles, that both encodings work, and that the port is
    really down afterwards — the class of bug that only a request-level test catches.

Also checked in the same pass

Every state payload comes from fullState() (structurally, over the source, and over HTTP for every endpoint that
returns one), the WebSocket connect frame and every broadcast carry the same shape, and the per-payload cost of
the cable verdicts stays inside a budget (5.3 ms for a 200-cable lab, against a 60 ms tripwire).

Found while auditing that every state payload carries the same shape after #1304/#1305. It is unrelated to that work and much worse. ## 1. The inspector's shutdown toggle does nothing on most of the catalogue `POST /api/topologies/:name/interfaces/:device/:port` required exactly one path segment for the port (`parts.length === 6`). But a port name is `1/1/1`, `Fa0/1`, `Gi0/0/2` — it contains slashes. So the URL the UI builds splits into extra segments and the endpoint never matches. Measured against a live server: ``` POST /api/topologies/default/interfaces/d1/1/1/1 -> 404 {"error":"unknown endpoint: /api/topologies/default/interfaces/d1/1/1/1"} POST /api/topologies/default/interfaces/d1/1%2F1%2F1 -> 404 {"error":"interface not found"} ``` The plain form falls through to the 404 at the bottom of the router; the encoded form reaches the handler but is never decoded. So the ▲/▼ shutdown control in the inspector — rendered, wired, and inert — has never worked for any device whose port names use slashes, which is most of the catalogue. Nothing caught it because every test drives the engine directly, not the URL. ## 2. `state` appears twice in one response object `POST /api/topologies/:name/links/:id/state` returns: ```js { ok: true, linkId: parts[4], state: state, atMs, reconvergeAtMs, changed, convergence, state: fullState(topo) } ``` The link's own `'up'`/`'down'` string and the whole topology under the same key. It currently works **by luck**: JavaScript keeps the later key. Reorder those lines, or delete the second, and the entire UI stores `state: "down"` and blanks the board. ## What must be true instead * a port name in a URL may be the **rest of the path**, and percent-encoded names must be decoded — both forms reaching the same port, and the port actually changing state; * the cable-state response names its string `linkState`, so `state` means one thing: the topology payload that every other endpoint returns; * a test asserts, over real HTTP, that a slash-named port toggles, that both encodings work, and that the port is really down afterwards — the class of bug that only a request-level test catches. ## Also checked in the same pass Every state payload comes from `fullState()` (structurally, over the source, and over HTTP for every endpoint that returns one), the WebSocket connect frame and every broadcast carry the same shape, and the per-payload cost of the cable verdicts stays inside a budget (5.3 ms for a 200-cable lab, against a 60 ms tripwire).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge#1307
No description provided.