Skip to content

Re-running configure.py keeps every admin host (#891) - #903

Closed
chchatzop wants to merge 1 commit into
mainfrom
fix/891-a-rerun-keeps-every-admin-host
Closed

chchatzop wants to merge 1 commit into
mainfrom
fix/891-a-rerun-keeps-every-admin-host

Conversation

@chchatzop

Copy link
Copy Markdown
Collaborator

Fixes #891. Found reviewing #811.

What was wrong

configure.py's services-host question took the first configured ADMIN_HOSTMASKS entry as its default and, on a blank answer, wrote [that one] back. An operator with two hosts (home and phone) who re-ran configure.py and pressed Enter lost the second - silently - and the phone could no longer run admin commands. configure._current()'s own promise is that re-running never does that.

Two smaller faults in the same lines: it indexed the value directly, so a comma-separated string setting (which adminchat accepts) offered its first character as the default; and a wildcard first entry (*!*@*.home.net) was run through the validator as if just typed - Enter printed "That will not do: '*.home.net' has a '*' in it" about a value nobody entered.

What changed

  • The hosts are read the way the console itself reads them - adminchat.admin_host_patterns(): either form, deduplicated, host part only - and shown (Configured now: ...), with the prompt saying what blank does.
  • A blank answer writes nothing. A host already configured changes nothing. A new host replaces a single configured one, exactly as before; beside several, it is added - one question cannot know which of several a new host replaces - and the operator is told how to remove one.
  • INSTALL.md's question list says what a re-run does; both changelogs.

Test

tests/test_a_rerun_of_configure_keeps_every_admin_host.py (8), through collect_answers() with canned input like #811's own tests: two hosts + blank writes nothing (the reported case); one host + blank; typing a host already there (case-insensitively); a new host beside several is added and they are kept; a new host replacing the only one; a wildcard entry is not put through the validator; a comma-separated setting read as hosts; and nothing configured behaving exactly as #811 wrote it. Six fail on the old code; the other two are the cases that deliberately do not change.

Two source guards followed the moved statements: #700's question-order guard anchors on the prompt's new home (a variable, at the same point in the source), and test_a_blank_answer_writes_nothing on the new condition - its property is now also executed by the tests above.

Verified

Full suite on current main: 6429 OK (18 skipped).

🤖 Generated with Claude Code

https://claude.ai/code/session_01AP6LSxkr4n9dMFNSNMogmW

The services-host question took the first configured ADMIN_HOSTMASKS
entry as its default and wrote [that one] back on a blank answer, so a
re-run with two hosts dropped the second silently. It also indexed the
value directly - a comma-separated setting offered its first character -
and ran a wildcard first entry through the validator as if typed.

Hosts are read as the console reads them (admin_host_patterns) and
shown; blank writes nothing, a host already there changes nothing, a new
one replaces a single host or is added beside several. Eight tests
through collect_answers(), six failing on the old code; two source
guards follow the moved statements. INSTALL.md and both changelogs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AP6LSxkr4n9dMFNSNMogmW
@chchatzop

Copy link
Copy Markdown
Collaborator Author

Superseded by #909 (merged), which fixed the reported case - Enter no longer collapses the hosts. Two cases this PR covered are still open on main and are filed separately rather than lost: retyping a host that is already configured still replaces all the others, and a comma-separated ADMIN_HOSTMASKS is read as characters. The chain that was stacked on this (#904 -> #905 -> #906) has been rebased onto main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Re-running configure.py collapses a multi-host ADMIN_HOSTMASKS to its first entry when the services-host prompt is left blank

1 participant