Skip to content

DeviceName: actionable error message when hyphen / uppercase / dot is used #23

Description

@ShortArrow

Context

`DeviceName` enforces `^[a-z][a-z0-9_]*$` (see
`src/IviCli.Domain/Devices/DeviceName.cs:19`) — no hyphens,
no uppercase, no dots, no leading digit.

When the user runs e.g. `ivicli visa add psu-mock ...`, the
error today is:

```
[WRN] invalid device name: psu-mock
error: invalid device name 'psu-mock'.
```

This doesn't tell the user why it's invalid or what to do
instead. ServerName allows hyphens
(`^[a-z][a-z0-9_-]*$`); PublicEndpoint allows hyphens too —
the inconsistency makes the right answer non-obvious.

Proposal

Either:

  • (a) Better error message: e.g.
    "invalid device name 'psu-mock': must match
    `[a-z][a-z0-9_]*` (lowercase letters, digits, underscores;
    must start with a letter). Try `psu_mock`."
  • (b) Relax the regex to match ServerName
    (`^[a-z][a-z0-9_-]*$`), removing the hyphen ban entirely.

Recommended: (b) for consistency. There's no underlying
constraint that forces device names to be hyphen-free
(VISA resource strings, config TOML, and audit log fields all
tolerate hyphens). Then update PRD / ADRs that document the
naming rule.

Acceptance

  • `ivicli visa add psu-mock ...` succeeds (option b), OR
  • the error message names the regex and suggests a fix (option a).
  • Tests under `tests/IviCli.Domain.Tests/Devices/` updated to
    the new rule.
  • PRD §6 (visa CRUD) updated if the constraint changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliCLI verbs, completion, help textenhancementNew feature or requestpriority:mediumImproves UX/security but not blocking

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions