A template whose start is a name is refused, not added to (#1525) #1558
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1558
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/1115-2236"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #1525
portTemplate.startis the first number in a run of port names; the expander treated it as an operand.Reproduced first (
devices/registry.jseffectiveInterfaces):What was wrong: the loader refused a non-numeric
start/prefix, but only the loader � the importer, an audit script andTopology.addDevice()on a generated spec all reacheffectiveInterfaces()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()indevices/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: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 leavingdevices.size === 0, the fractional / numeric-string / numeric-prefix spellings, the loader reporting the file, and that the supported form,start: 0and an absentstartall expand exactly as before.docs/DEVICE_SCHEMA.mdnow 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.js325 files OK;audit-port-typesandcheck-control-bytesclean; full suite 255 suites, 9313 assertions, 0 failed.startis a name is refused, not added to (#1525)`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.610e324fd31a3efa42e2