spanning-tree portfast, vlan 20 name lab and do show vlan each answered a different question #1493

Closed
opened 2026-11-12 06:21:05 +00:00 by jaylouisw · 1 comment
Owner

The symptom

I set out to check that configuration survives save and reopen, and it does: 73 config keys across four devices, 0 lost, 0 changed, and twelve show views byte-identical before and after. The five persistence fixes (#1405, #1459, #1465, #1467, #1487) hold.

Building that probe is what found these. Three commands replied in the voice of a neighbouring command — and each answer looked plausible enough to believe.

spanning-tree portfast was answered as spanning-tree priority

The handler took tokens[2] as a bridge priority without reading tokens[1]:

sw1(config-if)#spanning-tree portfast
% Usage: spanning-tree priority <0-61440 in 4096 steps>

sw1(config-if)#spanning-tree cost 19
% 19 is not a valid bridge priority: it must be a multiple of 4096 (the low 12 bits are the system ID extension)

portfast is the most-typed command in a switching lab, and the console answered a question about priorities. cost 19 is worse: 19 is a number, so the refusal reads like a verdict on the number rather than on the word, and a reader has no reason to doubt it.

vlan 20 name lab created a VLAN called "name lab"

name is a keyword in IOS's vlan sub-mode, not part of the name. The engine joined every word after the id and stored the result — so show vlan, and every other screen that lists names, printed the keyword as data:

sw1(config)#vlan 20 name lab
VLAN 20 created (name: name lab)

Silently wrong data is worse than a refusal, because nothing about it looks like an error.

do show vlan rejected the command it was given

do passed tokens.slice(1) — still starting with show — into the show dispatcher, which expects the words after show:

sw1(config)#do show vlan
% Invalid show command: show vlan
sw1(config)#do show running-config
% Invalid show command: show running-config

Every do show … in every configuration session failed that way, echoing the command it had just failed to run. do show run is a reflex for anyone who has configured a switch, and it had never worked.

What changed

spanning-tree reads its verb before its value. A sub-command this device does not model says so, by name: % spanning-tree portfast is not modelled: this device runs one spanning tree, and its only tunable is spanning-tree priority <0-61440 in 4096 steps>``. A misspelling is unknown, and quoted back with the form that does exist. priority behaves exactly as before, including the 4096-ladder message with the nearest valid values, the per-VLAN refusal, and a new one: a word where a number belongs (spanning-tree priority high) is now quoted rather than coerced.

vlan reads the name keyword as a keyword. vlan 20 name lab → lab; vlan 20 lab → lab (the documented form, unchanged); vlan 20 → VLAN0020; a two-word name survives whole; vlan 40 name-lab is not eaten because the word only counts in front; vlan 20 name with no text is refused as incomplete and writes nothing. IOS's two-line form now meets a hint instead of a bare refusal:

sw1(config)#name lab
% There is no vlan sub-mode here: name the VLAN on its own line, `vlan <id> name <text>` (e.g. `vlan 20 name lab`)

do show … runs the command it was given, and do on anything else says what it does here rather than failing obscurely.

Evidence

test/command-answers-the-question.test.js — 27 checks, 27 passed / 0 failed. With the old handler: 11 passed / 16 failed, each naming the neighbour's answer it used to give (portfast -> Usage: spanning-tree priority, vlan 20 name lab -> name lab, do show vlan -> Invalid show command: show vlan).

The test keeps the distinction that matters: a real IOS sub-command this model does not implement is refused as not modelled, while a misspelling is refused as unknown — so the two no longer read identically. It also pins what must not regress: priority 4096 applies and stores, priority 5000 names 4096 and 8192, nothing is written when refused, and vlan 20 lab still means what the docs say.

Docs: docs/CLI.md, new section "Three commands that answered a question nobody asked", with before/after transcripts; the two VLAN table rows now read vlan <id> [name] <text>.

Full suite: 244 suites, 9,070 assertions, 0 failed. Syntax 313 files.

## The symptom I set out to check that configuration survives save and reopen, and it does: **73 config keys across four devices, 0 lost, 0 changed**, and twelve `show` views byte-identical before and after. The five persistence fixes (#1405, #1459, #1465, #1467, #1487) hold. Building that probe is what found these. Three commands replied in the voice of a neighbouring command — and each answer looked plausible enough to believe. ### `spanning-tree portfast` was answered as `spanning-tree priority` The handler took `tokens[2]` as a bridge priority without reading `tokens[1]`: ``` sw1(config-if)#spanning-tree portfast % Usage: spanning-tree priority <0-61440 in 4096 steps> sw1(config-if)#spanning-tree cost 19 % 19 is not a valid bridge priority: it must be a multiple of 4096 (the low 12 bits are the system ID extension) ``` `portfast` is the most-typed command in a switching lab, and the console answered a question about priorities. `cost 19` is worse: 19 *is* a number, so the refusal reads like a verdict on the number rather than on the word, and a reader has no reason to doubt it. ### `vlan 20 name lab` created a VLAN called "name lab" `name` is a keyword in IOS's vlan sub-mode, not part of the name. The engine joined every word after the id and stored the result — so `show vlan`, and every other screen that lists names, printed the keyword as data: ``` sw1(config)#vlan 20 name lab VLAN 20 created (name: name lab) ``` Silently wrong data is worse than a refusal, because nothing about it looks like an error. ### `do show vlan` rejected the command it was given `do` passed `tokens.slice(1)` — still starting with `show` — into the `show` dispatcher, which expects the words *after* `show`: ``` sw1(config)#do show vlan % Invalid show command: show vlan sw1(config)#do show running-config % Invalid show command: show running-config ``` Every `do show …` in every configuration session failed that way, echoing the command it had just failed to run. `do show run` is a reflex for anyone who has configured a switch, and it had never worked. ## What changed **`spanning-tree` reads its verb before its value.** A sub-command this device does not model says so, by name: `% spanning-tree portfast is not modelled: this device runs one spanning tree, and its only tunable is `spanning-tree priority <0-61440 in 4096 steps>``. A misspelling is *unknown*, and quoted back with the form that does exist. `priority` behaves exactly as before, including the 4096-ladder message with the nearest valid values, the per-VLAN refusal, and a new one: a word where a number belongs (`spanning-tree priority high`) is now quoted rather than coerced. **`vlan` reads the `name` keyword as a keyword.** `vlan 20 name lab` → `lab`; `vlan 20 lab` → `lab` (the documented form, unchanged); `vlan 20` → `VLAN0020`; a two-word name survives whole; `vlan 40 name-lab` is not eaten because the word only counts in front; `vlan 20 name` with no text is refused as incomplete and writes nothing. IOS's two-line form now meets a hint instead of a bare refusal: ``` sw1(config)#name lab % There is no vlan sub-mode here: name the VLAN on its own line, `vlan <id> name <text>` (e.g. `vlan 20 name lab`) ``` **`do show …` runs the command it was given**, and `do` on anything else says what it does here rather than failing obscurely. ## Evidence `test/command-answers-the-question.test.js` — **27 checks, 27 passed / 0 failed**. With the old handler: **11 passed / 16 failed**, each naming the neighbour's answer it used to give (`portfast -> Usage: spanning-tree priority`, `vlan 20 name lab -> name lab`, `do show vlan -> Invalid show command: show vlan`). The test keeps the distinction that matters: a real IOS sub-command this model does not implement is refused as *not modelled*, while a misspelling is refused as *unknown* — so the two no longer read identically. It also pins what must not regress: `priority 4096` applies and stores, `priority 5000` names 4096 and 8192, nothing is written when refused, and `vlan 20 lab` still means what the docs say. Docs: `docs/CLI.md`, new section "Three commands that answered a question nobody asked", with before/after transcripts; the two VLAN table rows now read `vlan <id> [name] <text>`. Full suite: 244 suites, 9,070 assertions, 0 failed. Syntax 313 files.
Author
Owner

Landed as #1494 (913b0bec). Post-merge on main: command-answers-the-question 27/27, stp-priority 41/41, show-vlan 29/29, tree clean, 0 open PRs.

The config round-trip that led here is clean and stays worth knowing: 73 keys across four devices, 0 lost, 0 changed after save and reopen, and twelve show views byte-identical. What it found was not a persistence bug but three handlers that read the wrong token - tokens[2] before tokens[1], name as data, slice(1) where slice(2) belonged. A wrong token produces a fluent answer, which is why each of these read as correct for as long as it did.

Landed as #1494 (`913b0bec`). Post-merge on `main`: `command-answers-the-question` 27/27, `stp-priority` 41/41, `show-vlan` 29/29, tree clean, 0 open PRs. The config round-trip that led here is clean and stays worth knowing: 73 keys across four devices, 0 lost, 0 changed after save and reopen, and twelve `show` views byte-identical. What it found was not a persistence bug but three handlers that read the wrong token - `tokens[2]` before `tokens[1]`, `name` as data, `slice(1)` where `slice(2)` belonged. A wrong token produces a fluent answer, which is why each of these read as correct for as long as it did.
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#1493
No description provided.