A template whose start is a name is refused, not added to (#1525) #1558

Merged
jaylouisw merged 1 commit from fix/1115-2236 into main 2026-11-15 23:15:58 +00:00
Owner

Fixes #1525

portTemplate.start is the first number in a run of port names; the expander treated it as an operand.

Reproduced first (devices/registry.js effectiveInterfaces):

{ prefix: 'Gi', start: '1/0/1', count: 4 }   ->  Gi1/0/10 Gi1/0/11 Gi1/0/12 Gi1/0/13
{ prefix: 5, start: 1, count: 3 }                ->  "6" "7" "8"

What was wrong: the loader refused a non-numeric start/prefix, but only the loader � the importer, an audit script and Topology.addDevice() on a generated spec all reach effectiveInterfaces() without ever reading a file, so the refusal never arrived at those doors and the arithmetic ran.

Fix: the two rules now live next to portCountProblem() in devices/registry.js (portStartProblem(), portPrefixProblem()). The expander throws before a port is named, with a sentence that states the prefix/start split and shows the form that works:

portTemplate.start must be a whole number from 0 up, got "1/0/1" - the chassis belongs in "prefix" and the numbering in "start", so {"prefix":"Gi1/0/","start":1} names the first port Gi1/0/1

The loader calls the same functions and does it before its effectiveInterfaces() call, so a bad file is still reported against the file (and the catalogue still loads � no exception out of the middle of the walk). addDevice() throws before the device exists, so no half-built box is left on the board.

Kept as a test in test/template-expansion.test.js (16 new assertions): the refusal, the sentence naming the split, the engine path leaving devices.size === 0, the fractional / numeric-string / numeric-prefix spellings, the loader reporting the file, and that the supported form, start: 0 and an absent start all expand exactly as before.

docs/DEVICE_SCHEMA.md now says which half of a name goes in which field, and that both rules are enforced by the expander rather than only by the loader.

Gates: node scripts/syntax-check.js 325 files OK; audit-port-types and check-control-bytes clean; full suite 255 suites, 9313 assertions, 0 failed.

Fixes #1525 `portTemplate.start` is the first **number** in a run of port names; the expander treated it as an operand. **Reproduced first** (`devices/registry.js` `effectiveInterfaces`): ```js { prefix: 'Gi', start: '1/0/1', count: 4 } -> Gi1/0/10 Gi1/0/11 Gi1/0/12 Gi1/0/13 { prefix: 5, start: 1, count: 3 } -> "6" "7" "8" ``` **What was wrong:** the loader refused a non-numeric `start`/`prefix`, but only the loader � the importer, an audit script and `Topology.addDevice()` on a generated spec all reach `effectiveInterfaces()` without ever reading a file, so the refusal never arrived at those doors and the arithmetic ran. **Fix:** the two rules now live next to `portCountProblem()` in `devices/registry.js` (`portStartProblem()`, `portPrefixProblem()`). The expander throws before a port is named, with a sentence that states the prefix/start split and shows the form that works: ``` portTemplate.start must be a whole number from 0 up, got "1/0/1" - the chassis belongs in "prefix" and the numbering in "start", so {"prefix":"Gi1/0/","start":1} names the first port Gi1/0/1 ``` The loader calls the same functions and does it before its `effectiveInterfaces()` call, so a bad file is still reported against the file (and the catalogue still loads � no exception out of the middle of the walk). `addDevice()` throws before the device exists, so no half-built box is left on the board. **Kept as a test** in `test/template-expansion.test.js` (16 new assertions): the refusal, the sentence naming the split, the engine path leaving `devices.size === 0`, the fractional / numeric-string / numeric-prefix spellings, the loader reporting the file, and that the supported form, `start: 0` and an absent `start` all expand exactly as before. `docs/DEVICE_SCHEMA.md` now says which half of a name goes in which field, and that both rules are enforced by the expander rather than only by the loader. **Gates:** `node scripts/syntax-check.js` 325 files OK; `audit-port-types` and `check-control-bytes` clean; full suite **255 suites, 9313 assertions, 0 failed**.
A template whose start is a name is refused, not added to (#1525)
All checks were successful
CI / Classify the change (pull_request) Successful in 18s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 23s
CI / Test (Node 18) (pull_request) Successful in 3m31s
CI / Test (Node 20) (pull_request) Successful in 3m18s
CI / Server smoke test (pull_request) Successful in 33s
CI / Docker build (pull_request) Successful in 22s
CI / Test (Node 22) (pull_request) Successful in 3m5s
610e324fd3
`portTemplate.start` is the first *number* in a run of port names, and the expander
treated it as an operand: `{prefix: "Gi", start: "1/0/1", count: 4}` produced
Gi1/0/10 .. Gi1/0/13 - four plausible ports running past the end of the box, with
every address, VLAN and cable attached to a port that does not exist. A numeric
`prefix` had the same shape (ports named "6", "7", "8").

The loader already refused both, but only the loader: the importer, an audit and
`addDevice()` all reach `effectiveInterfaces()` without reading a file, so the
refusal never arrived for the specs those doors build. The two rules now live with
`portCountProblem()` in `devices/registry.js` (`portStartProblem()`,
`portPrefixProblem()`) and the expander throws before naming a port, with a sentence
that states the prefix/start split and shows the form that works. The loader calls
the same functions, before its `effectiveInterfaces()` call, so a bad file is still
reported against the file rather than throwing out of the catalogue walk.

test/template-expansion.test.js asserts the refusal, the sentence, the engine path
leaving no half-built device, the fractional/numeric-string/numeric-prefix
spellings, and that the supported form, `start: 0` and an absent `start` are
untouched. docs/DEVICE_SCHEMA.md says which half goes where.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-15 23:15:44 +00:00
jaylouisw force-pushed fix/1115-2236 from 610e324fd3
All checks were successful
CI / Classify the change (pull_request) Successful in 18s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 23s
CI / Test (Node 18) (pull_request) Successful in 3m31s
CI / Test (Node 20) (pull_request) Successful in 3m18s
CI / Server smoke test (pull_request) Successful in 33s
CI / Docker build (pull_request) Successful in 22s
CI / Test (Node 22) (pull_request) Successful in 3m5s
to 1a3efa42e2
All checks were successful
CI / Classify the change (pull_request) Successful in 16s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 20s
CI / Test (Node 18) (pull_request) Successful in 3m32s
CI / Test (Node 20) (pull_request) Successful in 3m14s
CI / Server smoke test (pull_request) Successful in 33s
CI / Docker build (pull_request) Successful in 21s
CI / Test (Node 22) (pull_request) Successful in 3m4s
2026-11-15 23:15:47 +00:00
Compare
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!1558
No description provided.