Let an empty IRC_LISTEN_ADDR disable the IRC listener (closes #124) #137

Merged
clawbot merged 1 commits from issue-124-irc-listen-off into next 2026-10-20 12:35:20 +02:00
Collaborator

Closes #124.

Viper counts an environment variable set to the empty string as unset, so IRC_LISTEN_ADDR= fell back to :6667 and the IRC listener could only be disabled through neoirc.yaml. config.New now also reads IRC_LISTEN_ADDR with os.LookupEnv: when the variable is set, its value is used, so the empty string disables the listener; when it is unset, the file's value or the :6667 default applies as before.

The new internal/config/config_test.go covers both cases. In README.md, the Configuration section names this as the one exception to "an empty environment variable counts as unset", the table row says how to disable the listener, and the IRC Protocol Listener section shows both the environment form and the neoirc.yaml form.

Judgement call: Viper does have a switch that honours empty environment variables (AllowEmptyEnv), but it applies to every setting at once, so PORT= or DBURL= would then mean an empty value instead of the default. That goes beyond this issue and contradicts what README.md documents, so only this one variable is read with os.LookupEnv.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/neoirc/issues/124. Viper counts an environment variable set to the empty string as unset, so `IRC_LISTEN_ADDR=` fell back to `:6667` and the IRC listener could only be disabled through `neoirc.yaml`. `config.New` now also reads `IRC_LISTEN_ADDR` with `os.LookupEnv`: when the variable is set, its value is used, so the empty string disables the listener; when it is unset, the file's value or the `:6667` default applies as before. The new `internal/config/config_test.go` covers both cases. In `README.md`, the Configuration section names this as the one exception to "an empty environment variable counts as unset", the table row says how to disable the listener, and the IRC Protocol Listener section shows both the environment form and the `neoirc.yaml` form. Judgement call: Viper does have a switch that honours empty environment variables (`AllowEmptyEnv`), but it applies to every setting at once, so `PORT=` or `DBURL=` would then mean an empty value instead of the default. That goes beyond this issue and contradicts what `README.md` documents, so only this one variable is read with `os.LookupEnv`. Model: opus-5-5
clawbot added the needs-review label 2026-10-20 12:06:38 +02:00
clawbot self-assigned this 2026-10-20 12:06:38 +02:00
clawbot added 1 commit 2026-10-20 12:06:39 +02:00
Viper treats an environment variable set to the empty string as unset,
so an empty IRC_LISTEN_ADDR fell back to the :6667 default and the IRC
listener could not be disabled from the environment. The config now
reads IRC_LISTEN_ADDR with os.LookupEnv as well, so an empty value
disables the listener and an unset one keeps :6667. Viper's own switch
for this applies to every setting, so it is not used. New config tests
cover both cases, and README.md says how to disable the listener.

Model: opus-5-5
Author
Collaborator

PASS: an IRC_LISTEN_ADDR set to the empty string now starts the server without the IRC listener, an unset one keeps :6667, and a value from neoirc.yaml still applies, which meets the definition of done in #124.

Model: opus-5-5

PASS: an `IRC_LISTEN_ADDR` set to the empty string now starts the server without the IRC listener, an unset one keeps `:6667`, and a value from `neoirc.yaml` still applies, which meets the definition of done in https://git.eeqj.de/sneak/neoirc/issues/124. Model: opus-5-5
clawbot merged commit 5b430cf835 into next 2026-10-20 12:35:20 +02:00
clawbot deleted branch issue-124-irc-listen-off 2026-10-20 12:35:22 +02:00
Sign in to join this conversation.