The interface door half-applies a body: a refused change still lands #1425

Closed
opened 2026-11-11 05:19:17 +00:00 by jaylouisw · 0 comments
Owner

POST /api/topologies/:name/interfaces/:device/:port writes four things — the address, enabled, description and the cage's role — and it writes them as it goes, in that order, answering 400 the moment one of them is refused. Measured against a live server on a managed switch:

POST {"ip":"10.9.9.9","mask":"255.255.255.0","role":"bogus"}
  -> 400 {"error":"1 cannot be bogus; it has no configurable role"}
  -> and the port now holds ip 10.9.9.9 / 255.255.255.0

The caller is told the change failed while half of it happened. After that the board and the sentence about the board disagree, and a person who reads "refused", reloads, and finds a configured port has no way to know which of the two to believe. #1413 promised this door "changes nothing on refusal" — that held only when the refused field happened to come first.

Two more questions in the same handler are asked wrongly:

POST {"enabled":"false"}   -> 200, and the port is ENABLED     (the door asks !!body.enabled)
POST {"enabled":0}         -> 200, and the port is ENABLED
POST {"description":42}    -> 200, and the description is 42

And a role refusal reads 1 cannot be bogus; it has no configurable role, which parses as a count of one, not as a port named 1.

What should be true

  1. a refusal changes nothing: the port's configuration is byte-identical afterwards;
  2. a body with several bad fields reports all of them, not the first — a client that sent three should learn about three, each with a code and a sentence;
  3. enabled is a boolean or a refusal that quotes what it was given; description is a string or a refusal;
  4. the address and its mask are one field, so an address that is not an address is refused before the mask is asked about;
  5. a refusal about a port names the port (port 1 cannot be bogus);
  6. and the door still applies valid bodies — a door that refused everything would satisfy 1–5.
`POST /api/topologies/:name/interfaces/:device/:port` writes four things — the address, `enabled`, `description` and the cage's role — and it writes them **as it goes, in that order**, answering `400` the moment one of them is refused. Measured against a live server on a managed switch: ``` POST {"ip":"10.9.9.9","mask":"255.255.255.0","role":"bogus"} -> 400 {"error":"1 cannot be bogus; it has no configurable role"} -> and the port now holds ip 10.9.9.9 / 255.255.255.0 ``` The caller is told the change failed while half of it happened. After that the board and the sentence about the board disagree, and a person who reads "refused", reloads, and finds a configured port has no way to know which of the two to believe. #1413 promised this door "changes nothing on refusal" — that held only when the refused field happened to come first. Two more questions in the same handler are asked wrongly: ``` POST {"enabled":"false"} -> 200, and the port is ENABLED (the door asks !!body.enabled) POST {"enabled":0} -> 200, and the port is ENABLED POST {"description":42} -> 200, and the description is 42 ``` And a role refusal reads `1 cannot be bogus; it has no configurable role`, which parses as a count of one, not as a port named `1`. ### What should be true 1. a refusal changes **nothing**: the port's configuration is byte-identical afterwards; 2. a body with several bad fields reports **all** of them, not the first — a client that sent three should learn about three, each with a code and a sentence; 3. `enabled` is a boolean or a refusal that quotes what it was given; `description` is a string or a refusal; 4. the address and its mask are one field, so an address that is not an address is refused before the mask is asked about; 5. a refusal about a port names the port (`port 1 cannot be bogus`); 6. and the door still applies valid bodies — a door that refused everything would satisfy 1–5.
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#1425
No description provided.