A spec can give two ports one name (5 ports become 4), declare a model another file already declares, and expand to nonsense — the schema says otherwise #1317

Closed
opened 2026-11-10 02:07:53 +00:00 by jaylouisw · 0 comments
Owner

docs/DEVICE_SCHEMA.md already says, in the interface table:

name | required, unique in the spec. Two ports called ge1 are an error, not a typo to fix silently.

and, in its own section:

Duplicate spellings are refused. ... two entries for one device make the palette look richer and the search
results wrong.

Neither was true at load. The importer enforced the second; loadCatalog() enforced neither. Measured on the
current tree:

specs with duplicate port names: 0
duplicate model keys:            0

so the catalogue is clean — and nothing keeps it that way. Three ways of lying are accepted today.

1. Two ports with one name: the spec describes 5, the device has 4

expandInterfaces(spec)   -> Gi1,Gi2,Gi3,Gi4,Gi2    (five ports)
device.interfaces.size   -> 4                      (four)

Ports are kept in a map keyed by name, so the later Gi2 silently replaces the earlier one. A 28-port switch written
with a clash becomes a 27-port switch, and nothing anywhere says so — the canvas, the inspector count and the port
audit all agree with each other and all disagree with the file.

2. Two files for one box

modelKey() squashes punctuation and is what the importer gates on (issue #60), but nothing re-checks it at load, so
a file that arrives by a rebase, a copy or a hand edit puts two entries in the palette for one machine. Then
POST /api/topologies/default/devices {model} takes whichever sorted first, and the box you cab is not necessarily
the one you read about.

3. A template prefix or start of the wrong type

prefix: 5 with start: "1" expands to Gi10, Gi11, Gi12, Gi13 — port numbering that begins at ten because
start + i concatenated a string. No rule was broken by any single field; the result is nonsense.

What must be true instead

  • a spec that gives two ports one name is refused, and the message carries the arithmetic: which name, and how many
    ports the device would really keep;
  • a spec whose model another file already declares is refused, naming the file that has it — comparison ignores
    punctuation, as the importer's does;
  • portTemplate.prefix must be a string and start a whole number ≥ 0 when present;
  • all three are enforced at load, not only at import, because import is not the only door;
  • and the shapes the catalogue actually uses still load: 207 template-only specs, template-plus-explicit mixes like
    "24x RJ45 + 4x SFP", explicit-only, and a template with no start.
`docs/DEVICE_SCHEMA.md` already says, in the interface table: > `name` | required, **unique in the spec**. Two ports called `ge1` are an error, not a typo to fix silently. and, in its own section: > **Duplicate spellings are refused.** ... two entries for one device make the palette look richer and the search > results wrong. Neither was true at load. The importer enforced the second; `loadCatalog()` enforced neither. Measured on the current tree: ``` specs with duplicate port names: 0 duplicate model keys: 0 ``` so the catalogue is clean — and nothing keeps it that way. Three ways of lying are accepted today. ## 1. Two ports with one name: the spec describes 5, the device has 4 ```js expandInterfaces(spec) -> Gi1,Gi2,Gi3,Gi4,Gi2 (five ports) device.interfaces.size -> 4 (four) ``` Ports are kept in a map keyed by name, so the later `Gi2` silently replaces the earlier one. A 28-port switch written with a clash becomes a 27-port switch, and nothing anywhere says so — the canvas, the inspector count and the port audit all agree with each other and all disagree with the file. ## 2. Two files for one box `modelKey()` squashes punctuation and is what the importer gates on (issue #60), but nothing re-checks it at load, so a file that arrives by a rebase, a copy or a hand edit puts two entries in the palette for one machine. Then `POST /api/topologies/default/devices {model}` takes whichever sorted first, and the box you cab is not necessarily the one you read about. ## 3. A template prefix or start of the wrong type `prefix: 5` with `start: "1"` expands to `Gi10, Gi11, Gi12, Gi13` — port numbering that begins at ten because `start + i` concatenated a string. No rule was broken by any single field; the result is nonsense. ## What must be true instead * a spec that gives two ports one name is refused, and the message carries the arithmetic: which name, and how many ports the device would really keep; * a spec whose `model` another file already declares is refused, naming the file that has it — comparison ignores punctuation, as the importer's does; * `portTemplate.prefix` must be a string and `start` a whole number ≥ 0 when present; * all three are enforced at **load**, not only at import, because import is not the only door; * and the shapes the catalogue actually uses still load: 207 template-only specs, template-plus-explicit mixes like "24x RJ45 + 4x SFP", explicit-only, and a template with no `start`.
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#1317
No description provided.