cli(hostname): a name past 63 characters is refused, and the old name kept #2535

Closed
jaylouisw wants to merge 1 commit from fix/1124-0532 into main
Owner

Fixes #2532

hostname <64+ characters> renamed the device on every surface - the config line, device.name, the prompt, the canvas label - into a name no box of that lineage will hold. Every IOS and IOS XE reference states the ceiling as a rule of the command ("Names must be 63 characters or fewer"), and a 3560 on IOS 12.2(55) refuses the 64th character with one fixed sentence and keeps the old name.

sw1(config)#hostname aaaa...aaaa        <- 64 characters
% Hostname must have more than 1 character and must not exceed the maximum 63 character length.
  64 characters, so the name is still "sw1"
  • engine/cli.js: HOSTNAME_MAX = 63 + hostnameLengthRefusal(), asked after the help-key refusal and before the all-numeric warning (a 64-digit name breaches both rules and a box answers the one that stops the command). A refusal stores nothing, so no partial rename is left to undo; 63 characters are still taken whole.
  • test/hostname-length-limit.test.js (new): 34 checks - the boundary taken on every surface, the 64th refused with all state unchanged, the count on a 200-character name, spaces counted at the boundary, the length refusal outranking the warning, and no hostname / a shorter rename still working afterwards. With the old handler: 14 passed / 20 failed.
  • test/config-roundtrip.test.js: the sweep seeds a legal name on the 52 models whose default label is over the ceiling - it was replaying a hostname line a real box rejects. The printer question (should an unrenamed device print a hostname line at all) stays open, as item 2 of the issue.
  • docs/CLI.md, research/hostname-length-limit.md, CHANGELOG.md: the rule, the citations, the decision, and what is still unmodelled - the 1-character lower bound, the prompt field (20/30/12 characters), the per-platform ceilings 58 (Catalyst 1200/1300) and 32 (NX-OS).

Quality gates

  • node scripts/syntax-check.js: 563 files (554 JS, 9 TS), all OK.
  • Full npm test: 479 suites, 16,098 assertions, 0 failed (576 s).
Fixes #2532 `hostname <64+ characters>` renamed the device on every surface - the config line, `device.name`, the prompt, the canvas label - into a name no box of that lineage will hold. Every IOS and IOS XE reference states the ceiling as a rule of the command ("Names must be 63 characters or fewer"), and a 3560 on IOS 12.2(55) refuses the 64th character with one fixed sentence and keeps the old name. ``` sw1(config)#hostname aaaa...aaaa <- 64 characters % Hostname must have more than 1 character and must not exceed the maximum 63 character length. 64 characters, so the name is still "sw1" ``` - `engine/cli.js`: `HOSTNAME_MAX = 63` + `hostnameLengthRefusal()`, asked after the help-key refusal and **before** the all-numeric warning (a 64-digit name breaches both rules and a box answers the one that stops the command). A refusal stores nothing, so no partial rename is left to undo; 63 characters are still taken whole. - `test/hostname-length-limit.test.js` (new): 34 checks - the boundary taken on every surface, the 64th refused with all state unchanged, the count on a 200-character name, spaces counted at the boundary, the length refusal outranking the warning, and `no hostname` / a shorter rename still working afterwards. With the old handler: 14 passed / 20 failed. - `test/config-roundtrip.test.js`: the sweep seeds a legal name on the 52 models whose default label is over the ceiling - it was replaying a `hostname` line a real box rejects. The printer question (should an unrenamed device print a `hostname` line at all) stays open, as item 2 of the issue. - `docs/CLI.md`, `research/hostname-length-limit.md`, `CHANGELOG.md`: the rule, the citations, the decision, and what is still unmodelled - the 1-character lower bound, the prompt field (20/30/12 characters), the per-platform ceilings 58 (Catalyst 1200/1300) and 32 (NX-OS). ### Quality gates - `node scripts/syntax-check.js`: 563 files (554 JS, 9 TS), all OK. - Full `npm test`: **479 suites, 16,098 assertions, 0 failed** (576 s).
cli(hostname): a name past 63 characters is refused, and the old name kept (#2532)
All checks were successful
CI / Typecheck (pull_request) Successful in 18s
CI / Server smoke and Docker build (pull_request) Successful in 50s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 14s
CI / Test (Node 22) (pull_request) Successful in 49s
CI / Test (Node 24) (pull_request) Successful in 53s
CI / Arm auto-merge (pull_request) Successful in 4s
e756e39ebb
Every IOS and IOS XE `hostname` reference states the ceiling as a rule of the command - "Names must be
63 characters or fewer" - and a Catalyst 3560 on IOS 12.2(55) refuses the 64th character with one fixed
sentence, leaving the prompt and the running-config on the name it already had. The console had no length
rule at all, so `hostname <64+ characters>` renamed the device on every surface - the config line,
`device.name`, the prompt, the canvas label - into a name no box will hold.

The refusal is two lines: the vendor's sentence verbatim, then this house's count and the name that
survived, the same shape `hostname` with no name uses (#1497). It sits after the help-key refusal and
before the all-numeric warning - a 64-digit name breaches both rules and a box answers the one that stops
the command - and it stores nothing, so no partial rename is left to undo. 63 characters are still taken
whole.

test/hostname-length-limit.test.js: 34 checks (14 passed / 20 failed on the old handler).
test/config-roundtrip.test.js: the sweep seeds a legal name on the 52 models whose default label is over
the ceiling, because it was replaying a `hostname` line a real box rejects; the printer question - whether
an unrenamed device should print one at all - stays open in #2532.

docs/CLI.md and research/hostname-length-limit.md carry the rule, the citations and what is still
unmodelled (the 1-character lower bound, the prompt field, the per-platform ceilings 32/58).

node scripts/syntax-check.js: 563 files, all OK.
Full suite: 479 suites, 16,098 assertions, 0 failed.

Arm auto-merge went green but could not arm this pull request.

Every status on e756e39ebb86cd2ada1415899b0aae7cff9f0847 is success, so the gate
approved the change; the arm call was refused:

HTTP 405 {"message":"Please try again later","url":"https://git.jayw.uk/api/swagger"}

The branch is untouched and the scheduled pass will try again. This
comment exists because the job log needs a login to read.

**Arm auto-merge went green but could not arm this pull request.** Every status on `e756e39ebb86cd2ada1415899b0aae7cff9f0847` is `success`, so the gate approved the change; the arm call was refused: ``` HTTP 405 {"message":"Please try again later","url":"https://git.jayw.uk/api/swagger"} ``` The branch is untouched and the scheduled pass will try again. This comment exists because the job log needs a login to read.
jaylouisw closed this pull request 2026-11-24 06:09:43 +00:00
Author
Owner

Superseded — main already carries this change.

3367120a (squash of #2532, merged 05:37Z today) landed the same behaviour on engine/cli.js: HOSTNAME_MAX = 63, hostnameLengthRefusal(), the check placed after _helpKeyRefusal and before the all-numeric warning, the vendor sentence verbatim plus the N characters, so the name is still "..." second line, test/hostname-length-limit.test.js (121 lines), and the four over-long catalogue defaults seeded in test/config-roundtrip.test.js. The research doc was rewritten by that PR too.

This branch is the same work re-committed on a base two commits behind main (parent 7703e18b, before #2527/#2531/#2532 landed). Merging it locally into origin/main gives: CONFLICT (content) in engine/cli.js, research/hostname-length-limit.md, test/config-roundtrip.test.js; CONFLICT (add/add) in test/hostname-length-limit.test.js. That is duplicate work, not a defect — no rebase turns it into a change main does not already have.

Closed as superseded without merging. What differs from main is wording in the research doc and test comments plus a CHANGELOG.md entry, all describing the rule main now enforces.

If the cli loop intended a different length rule (e.g. enforcing the more than 1 character lower bound that research/hostname-length-limit.md leaves open), that is a new increment against current main — open it as a fresh PR and it gets picked up like any other.

Superseded — main already carries this change. `3367120a` (squash of #2532, merged 05:37Z today) landed the same behaviour on `engine/cli.js`: `HOSTNAME_MAX = 63`, `hostnameLengthRefusal()`, the check placed after `_helpKeyRefusal` and before the all-numeric warning, the vendor sentence verbatim plus the `N characters, so the name is still "..."` second line, `test/hostname-length-limit.test.js` (121 lines), and the four over-long catalogue defaults seeded in `test/config-roundtrip.test.js`. The research doc was rewritten by that PR too. This branch is the same work re-committed on a base two commits behind main (parent `7703e18b`, before #2527/#2531/#2532 landed). Merging it locally into `origin/main` gives: CONFLICT (content) in `engine/cli.js`, `research/hostname-length-limit.md`, `test/config-roundtrip.test.js`; CONFLICT (add/add) in `test/hostname-length-limit.test.js`. That is duplicate work, not a defect — no rebase turns it into a change main does not already have. Closed as superseded without merging. What differs from main is wording in the research doc and test comments plus a CHANGELOG.md entry, all describing the rule main now enforces. If the cli loop intended a *different* length rule (e.g. enforcing the `more than 1 character` lower bound that research/hostname-length-limit.md leaves open), that is a new increment against current main — open it as a fresh PR and it gets picked up like any other.
All checks were successful
CI / Typecheck (pull_request) Successful in 18s
CI / Server smoke and Docker build (pull_request) Successful in 50s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 14s
CI / Test (Node 22) (pull_request) Successful in 49s
CI / Test (Node 24) (pull_request) Successful in 53s
CI / Arm auto-merge (pull_request) Successful in 4s

Pull request closed

Sign in to join this conversation.
No description provided.