fix(config-ini): strip inline # and ; comments from values

The module docstring teaches inline comments — `mode = master    # or
"agent"` is the canonical example for the [decnet] section. Python's
configparser ignores those by default unless inline_comment_prefixes
is set explicitly, so the comment became part of the value and
downstream validators rejected it ("mode must be 'agent' or 'master',
got 'master                       # or \"agent\"'").

Hit live on first VPS deploy: every CLI invocation crashed at import
time with a stack trace that didn't make it obvious the docstring's
example was the trigger. Now the parser does what the docs promise.
This commit is contained in:
2026-04-27 22:55:58 -04:00
parent 0b1a17b4eb
commit c5db1d7ba2
2 changed files with 26 additions and 1 deletions

View File

@@ -158,7 +158,14 @@ def load_ini_config(path: Optional[Path] = None) -> Optional[Path]:
if not path.is_file():
return None
parser = configparser.ConfigParser()
# The docstring at the top of this module advertises inline ``#`` and
# ``;`` comments (e.g. ``mode = master # or "agent"``). Python's
# ``configparser`` only recognises those when ``inline_comment_prefixes``
# is set explicitly — without it, the comment becomes part of the value
# and downstream validators reject it ("mode must be 'agent' or 'master',
# got 'master # or \"agent\"'"). Match what the docs
# promise.
parser = configparser.ConfigParser(inline_comment_prefixes=("#", ";"))
parser.read(path)
# [decnet] first — mode/disallow-master/log-directory. These seed the