A mask the console refuses is refused by every door (#1413) #1414

Merged
jaylouisw merged 1 commit from fix/api-config-door into main 2026-11-11 02:29:19 +00:00
Owner

Closes #1413.

The endpoint asks the rule, not the parser. isIp() for the address, isContiguousMask() for the mask, and a refusal carries a code a client can act on - E_BAD_ADDRESS, E_BAD_MASK - with a sentence that says what a netmask is. A refused request changes nothing.

One intent, one spelling. A prefix length ("24") is rewritten to 255.255.255.0 before it is stored, which is what the console already did; the two doors had been disagreeing about the same command.

A loaded document is restored or explained. fromJSON() sweeps each port's address after hydration and records one entry per port in loadIssues, the channel cables already use: an old "24" is rewritten and the address kept; a mask that is not a mask, an address that cannot exist, or an address with no mask cost the port its address and say so by name - E_IFACE_BAD_MASK, E_IFACE_BAD_ADDRESS, E_IFACE_NO_MASK. The rest of the lab loads, instead of the whole document being refused with the engine's wording (400 Invalid IPv4 address: 300.1.1.1, board never replaced).

Evidence. test/api-config-door.test.js, 24 checks against a real server on a temp data dir:

  • a non-contiguous mask is a 400 E_BAD_MASK with a sentence about netmasks, and the port is untouched;
  • an impossible address is a 400 E_BAD_ADDRESS, and nothing is set;
  • mask: "24" is accepted and stored dotted, so the config prints ip address 10.5.5.1 255.255.255.0 and the port reads /24;
  • every mask form this door accepts is a line the console accepts - each printed ip address line is typed back into the console and no refusal is allowed (the property that was broken);
  • a document with a bad mask, a bad address and an old-style length loads, reports each in loadIssues naming port and value, rewrites the old spelling, leaves the good port alone, and leaves no impossible mask in state;
  • a saved board reloads as itself with an empty loadIssues.

Reverting server/index.js fails 8 of 24; reverting engine/topology.js fails 2 of 24. Suite: 208 suites, 7,989 assertions, 0 failed; syntax 276 files OK.

Docs: docs/ARCHITECTURE.md gains "A mask the console refuses is refused by every door" and "An address is restored or explained".

Closes #1413. **The endpoint asks the rule, not the parser.** `isIp()` for the address, `isContiguousMask()` for the mask, and a refusal carries a code a client can act on - `E_BAD_ADDRESS`, `E_BAD_MASK` - with a sentence that says what a netmask is. A refused request changes nothing. **One intent, one spelling.** A prefix length (`"24"`) is rewritten to `255.255.255.0` before it is stored, which is what the console already did; the two doors had been disagreeing about the same command. **A loaded document is restored or explained.** `fromJSON()` sweeps each port's address after hydration and records one entry per port in `loadIssues`, the channel cables already use: an old `"24"` is rewritten and the address kept; a mask that is not a mask, an address that cannot exist, or an address with no mask cost the port its address and say so by name - `E_IFACE_BAD_MASK`, `E_IFACE_BAD_ADDRESS`, `E_IFACE_NO_MASK`. The rest of the lab loads, instead of the whole document being refused with the engine's wording (`400 Invalid IPv4 address: 300.1.1.1`, board never replaced). **Evidence.** `test/api-config-door.test.js`, 24 checks against a real server on a temp data dir: - a non-contiguous mask is a 400 `E_BAD_MASK` with a sentence about netmasks, and the port is untouched; - an impossible address is a 400 `E_BAD_ADDRESS`, and nothing is set; - `mask: "24"` is accepted and stored dotted, so the config prints `ip address 10.5.5.1 255.255.255.0` and the port reads `/24`; - **every mask form this door accepts is a line the console accepts** - each printed `ip address` line is typed back into the console and no refusal is allowed (the property that was broken); - a document with a bad mask, a bad address and an old-style length loads, reports each in `loadIssues` naming port and value, rewrites the old spelling, leaves the good port alone, and leaves no impossible mask in state; - a saved board reloads as itself with an empty `loadIssues`. Reverting `server/index.js` fails **8 of 24**; reverting `engine/topology.js` fails **2 of 24**. Suite: **208 suites, 7,989 assertions, 0 failed**; syntax 276 files OK. Docs: `docs/ARCHITECTURE.md` gains "A mask the console refuses is refused by every door" and "An address is restored or explained".
A mask the console refuses is refused by every door (#1413)
Some checks failed
CI / Classify the change (pull_request) Successful in 12s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 14s
CI / Test (Node 20) (pull_request) Successful in 2m37s
CI / Test (Node 18) (pull_request) Successful in 2m49s
CI / Server smoke test (pull_request) Successful in 25s
CI / Docker build (pull_request) Successful in 39s
CI / Test (Node 22) (pull_request) Failing after 2m38s
14854411ce
The API edits a port directly, and it asked the parser rather than the rule: mask 255.0.255.0 was stored, read as /8 everywhere, and printed by show running-config as a line the console refuses to type - a lab that cannot be replayed from its own configuration. A prefix length was stored as "24" where the console stores 255.255.255.0. And POST /load took a whole document with no per-field validation, so a hand-edited file put an impossible mask into state (or the whole load 400'd, board untouched).

Now: the interface endpoint asks isIp() and isContiguousMask(), refuses with a code (E_BAD_ADDRESS / E_BAD_MASK) and a sentence, rewrites a prefix length to the dotted spelling, and changes nothing on refusal. fromJSON() restores or explains each port's address in loadIssues (E_IFACE_BAD_MASK / E_IFACE_BAD_ADDRESS / E_IFACE_NO_MASK) instead of adopting it or refusing the document wholesale.

test/api-config-door.test.js, 24 checks: refusals with codes and untouched state, one spelling in state, every accepted mask replayed through the console without a refusal, a bad document loading with issues that name the port and value, and a saved board reloading as itself. Reverting server/index.js fails 8 of 24, engine/topology.js 2 of 24.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-11 02:29:15 +00:00
Sign in to join this conversation.
No reviewers
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!1414
No description provided.