newsletters-healthy: Listmonk binds nixpkgs' default localhost:9000, never the mesh serve port — the render sets a flat "app.address" TOML key instead of settings.app.address #1308

Closed
opened 2026-09-07 23:15:08 +00:00 by matou-build-agent · 1 comment

The failure

Drive 20260907T221610Z (target brands, commit 8910b1bf) went red at leg newsletters-healthy after 360s of warm-up re-probe:

newsletters service is not healthy after 360s of warm-up re-probe (#556): Newsletters is not serving — Listmonk could not render a pānui and hand it to the community's mail service

16 of 17 legs green; deploy-newsletters itself was green (863907ms). The failure is not the deploy — it is that nothing is listening where the front door points.

The evidence

The probe never reaches Listmonk. Every one of the 74 probe attempts is a Caddy 502, and Caddy names the cause exactly (logs/guest-caddy.log:23 through :96, 22:52:09 → 23:07:11):

"msg":"dial tcp 127.0.0.1:9010: connect: connection refused",
"host":"newsletters.e2e-drive.idss.internal","uri":"/api/health","status":502

The control plane reports it as listmonk: the API is not answering — HTTP 502 (logs/guest-control-plane.log:130-201), raised at control-plane/cmd/control-plane/newslettershealth.go:203.

Listmonk is alive the whole time. logs/guest-resources.log (captured 23:07) shows the daemon running since 22:47:

listmonk   14117 ... /nix/store/24xviww3c13pnci3z7xs1yd07zhfnhhq-listmonk-6.1.0/bin/listmonk --config /nix/store/z1cyzv0crlfxhxg0pc6knvazbhpmhq0q-listmonk.toml
postgres   15137 ... postgres: listmonk listmonk [local] idle

and it logs from its own update checker at 23:02:43 (logs/guest-system-journal.log:293). logs/guest-failed-units.log lists 0 failed units. So the daemon is serving — just not on 9010.

The defect

internal/clan/newsletters.go:240 renders the bind address as a flat, dot-containing attribute name inside services.listmonk.settings:

fmt.Fprintf(b, "      \"app.address\" = %q; # bound to the mesh serve port (wt0), the front door's reverse-proxy target\n", fmt.Sprintf("[::]:%d", newslettersServePort))

The nixpkgs listmonk module (nixos/modules/services/mail/listmonk.nix) renders cfg.settings straight through pkgs.formats.toml and declares its own default on the nested path:

services.listmonk.settings."app".address = lib.mkDefault "localhost:9000";

Because IDSS never assigns settings.app.address, that mkDefault is never overridden. I verified the emitted TOML by running pkgs.formats.toml against the community flake's pinned nixpkgs (26.11pre1015397.173d0ad7a974, from state/clan-config/flake.lock) with exactly the attrset the render produces plus the module's default:

"app.address" = "[::]:9010"
"app.root_url" = "https://newsletters.example.nz"
"upload.path" = "/var/lib/listmonk"
"upload.provider" = "filesystem"

[app]
address = "localhost:9000"

[db]
...

A quoted TOML key "app.address" is a single literal key, not the [app]/address path. Listmonk (koanf, . delimiter) flattens both into the same lookup key app.address, so which one wins is Go map-iteration order — nondeterministic even in the best case. On this drive localhost:9000 won, so nothing ever bound 9010.

Meanwhile the front door is pointed at 9010 by internal/clan/portroute.go:113:

NewslettersSlug: {ServePort: newslettersServePort, ExemptPaths: NewslettersExemptPaths},

with newslettersServePort = 9010 (internal/clan/newsletters.go:101). Hence the mismatch.

Knock-on (same root cause, and why the journal is silent): the SMTP reconciler (internal/clan/newsletters.go:356) and the brand oneshot (internal/clan/newsletters.go:429) both drive http://[::1]:9010, so both are also talking to a closed port. The reconciler swallows it — curl -sf … || exit 0 at internal/clan/newsletters.go:363 — so it exits 0 and leaves no journal trace. That masking is worth a look alongside the fix.

The same slip covers three more keys — and their correct home is a design call

internal/clan/newsletters.go:241-243 renders "app.root_url", "upload.path" and "upload.provider" the same flat way. Nesting them would not fix them: in Listmonk these are rows in the settings table, not config.toml keys, and the DB settings are loaded over the file config at boot — so the TOML values are inert either way. ("upload.path" is not even a Listmonk key; the DB row is upload.filesystem.upload_path.) Their honest homes are either:

  • services.listmonk.database.settings — but that submodule's smtp option has no default, so making it non-null forces the module to declare the SMTP servers that ADR 0062 part 2 deliberately reconciles imperatively; and database.mutableSettings = false would re-run the SQL every start, fighting both the newsletters-smtp reconciler and the newsletters-brand oneshot (which sets app.logo_url through the API); or
  • folded into the existing API reconciler's settings PUT.

That choice is the ADR 0062 part-1 (declarative) / part-2 (out-of-band reconciled) seam, which is why this needs a ruling rather than a mechanical patch.

Suspected layer

The newsletters port render seam — internal/clan/newsletters.go, renderListmonkDaemon (lines 229-247). Product code, not harness: the drive caught a real deploy defect.

Why I refused to heal it — refusal rule 1

The minimal correct fix is to emit app.address = "[::]:9010"; as a nested attribute so it overrides the module's mkDefault. The render seam test hard-codes the current, wrong form:

// internal/clan/newsletters_test.go:41
if !strings.Contains(out, `"app.address" = "[::]:9010";`) {
    t.Fatalf("Listmonk must bind HTTP to the mesh serve port:\n%s", out)
}

There is no rendering of the corrected attribute path that still contains that literal, so any honest fix must edit that expectation line — refusal rule 1 (never edit an assertion/expectation line). internal/clan/newsletters_test.go:37 and :98 carry the same coupling for "app.root_url" and "upload.path".

Filed confident: false because (a) rule 1 fired, and (b) the root_url/upload half needs the ADR 0062 part-1/part-2 ruling described above before a worker can act.

Suggested shape once ruled

  1. internal/clan/newsletters.go:240 → render app.address = "[::]:9010"; nested under settings (overrides the module mkDefault); update internal/clan/newsletters_test.go:41 to prove the nested path, ideally asserting it is the path nixpkgs reads rather than a bare substring.
  2. Decide the home for app.root_url / upload.* per the ruling; update internal/clan/newsletters_test.go:37,98 to match.
  3. Consider dropping the || exit 0 mask at internal/clan/newsletters.go:363 so a closed serve port reds the reconciler instead of exiting 0 silently.
  4. Worth a docs/GOTCHAS.md entry: a dotted attribute name inside a pkgs.formats.toml settings attrset is a literal key, never a table path — it silently loses to the module's own mkDefault.

drive 20260907T221610Z red at newsletters-healthy: newsletters service is not healthy after 360s of warm-up re-probe (#556): Newsletters is not serving — Listmonk could not render a pānui and hand it to the community's mail service — this service
evidence: /home/swarm/swarm/Matou/idss/test-results/private-path/20260907T221610Z on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured

## The failure Drive `20260907T221610Z` (target `brands`, commit `8910b1bf`) went red at leg `newsletters-healthy` after 360s of warm-up re-probe: > newsletters service is not healthy after 360s of warm-up re-probe (#556): Newsletters is not serving — Listmonk could not render a pānui and hand it to the community's mail service 16 of 17 legs green; `deploy-newsletters` itself was green (863907ms). The failure is not the deploy — it is that nothing is listening where the front door points. ## The evidence **The probe never reaches Listmonk.** Every one of the 74 probe attempts is a Caddy 502, and Caddy names the cause exactly (`logs/guest-caddy.log:23` through `:96`, 22:52:09 → 23:07:11): ``` "msg":"dial tcp 127.0.0.1:9010: connect: connection refused", "host":"newsletters.e2e-drive.idss.internal","uri":"/api/health","status":502 ``` The control plane reports it as `listmonk: the API is not answering — HTTP 502` (`logs/guest-control-plane.log:130-201`), raised at `control-plane/cmd/control-plane/newslettershealth.go:203`. **Listmonk is alive the whole time.** `logs/guest-resources.log` (captured 23:07) shows the daemon running since 22:47: ``` listmonk 14117 ... /nix/store/24xviww3c13pnci3z7xs1yd07zhfnhhq-listmonk-6.1.0/bin/listmonk --config /nix/store/z1cyzv0crlfxhxg0pc6knvazbhpmhq0q-listmonk.toml postgres 15137 ... postgres: listmonk listmonk [local] idle ``` and it logs from its own update checker at 23:02:43 (`logs/guest-system-journal.log:293`). `logs/guest-failed-units.log` lists **0 failed units**. So the daemon is serving — just not on 9010. ## The defect `internal/clan/newsletters.go:240` renders the bind address as a **flat, dot-containing attribute name** inside `services.listmonk.settings`: ```go fmt.Fprintf(b, " \"app.address\" = %q; # bound to the mesh serve port (wt0), the front door's reverse-proxy target\n", fmt.Sprintf("[::]:%d", newslettersServePort)) ``` The nixpkgs listmonk module (`nixos/modules/services/mail/listmonk.nix`) renders `cfg.settings` straight through `pkgs.formats.toml` and declares its own default on the *nested* path: ```nix services.listmonk.settings."app".address = lib.mkDefault "localhost:9000"; ``` Because IDSS never assigns `settings.app.address`, that `mkDefault` is never overridden. I verified the emitted TOML by running `pkgs.formats.toml` against the community flake's pinned nixpkgs (`26.11pre1015397.173d0ad7a974`, from `state/clan-config/flake.lock`) with exactly the attrset the render produces plus the module's default: ```toml "app.address" = "[::]:9010" "app.root_url" = "https://newsletters.example.nz" "upload.path" = "/var/lib/listmonk" "upload.provider" = "filesystem" [app] address = "localhost:9000" [db] ... ``` A quoted TOML key `"app.address"` is a single literal key, **not** the `[app]`/`address` path. Listmonk (koanf, `.` delimiter) flattens both into the same lookup key `app.address`, so which one wins is Go map-iteration order — nondeterministic even in the best case. On this drive `localhost:9000` won, so nothing ever bound 9010. Meanwhile the front door is pointed at 9010 by `internal/clan/portroute.go:113`: ```go NewslettersSlug: {ServePort: newslettersServePort, ExemptPaths: NewslettersExemptPaths}, ``` with `newslettersServePort = 9010` (`internal/clan/newsletters.go:101`). Hence the mismatch. **Knock-on (same root cause, and why the journal is silent):** the SMTP reconciler (`internal/clan/newsletters.go:356`) and the brand oneshot (`internal/clan/newsletters.go:429`) both drive `http://[::1]:9010`, so both are also talking to a closed port. The reconciler swallows it — `curl -sf … || exit 0` at `internal/clan/newsletters.go:363` — so it exits 0 and leaves no journal trace. That masking is worth a look alongside the fix. ## The same slip covers three more keys — and their correct home is a design call `internal/clan/newsletters.go:241-243` renders `"app.root_url"`, `"upload.path"` and `"upload.provider"` the same flat way. Nesting them would **not** fix them: in Listmonk these are rows in the `settings` table, not `config.toml` keys, and the DB settings are loaded over the file config at boot — so the TOML values are inert either way. (`"upload.path"` is not even a Listmonk key; the DB row is `upload.filesystem.upload_path`.) Their honest homes are either: - `services.listmonk.database.settings` — but that submodule's `smtp` option has no default, so making it non-null forces the module to declare the SMTP servers that ADR 0062 part 2 deliberately reconciles imperatively; and `database.mutableSettings = false` would re-run the SQL every start, fighting both the `newsletters-smtp` reconciler and the `newsletters-brand` oneshot (which sets `app.logo_url` through the API); or - folded into the existing API reconciler's settings PUT. That choice is the ADR 0062 part-1 (declarative) / part-2 (out-of-band reconciled) seam, which is why this needs a ruling rather than a mechanical patch. ## Suspected layer The newsletters port render seam — `internal/clan/newsletters.go`, `renderListmonkDaemon` (lines 229-247). Product code, not harness: the drive caught a real deploy defect. ## Why I refused to heal it — refusal rule 1 The minimal correct fix is to emit `app.address = "[::]:9010";` as a nested attribute so it overrides the module's `mkDefault`. The render seam test hard-codes the *current, wrong* form: ```go // internal/clan/newsletters_test.go:41 if !strings.Contains(out, `"app.address" = "[::]:9010";`) { t.Fatalf("Listmonk must bind HTTP to the mesh serve port:\n%s", out) } ``` There is no rendering of the corrected attribute path that still contains that literal, so any honest fix must edit that expectation line — **refusal rule 1 (never edit an assertion/expectation line)**. `internal/clan/newsletters_test.go:37` and `:98` carry the same coupling for `"app.root_url"` and `"upload.path"`. Filed `confident: false` because (a) rule 1 fired, and (b) the root_url/upload half needs the ADR 0062 part-1/part-2 ruling described above before a worker can act. ## Suggested shape once ruled 1. `internal/clan/newsletters.go:240` → render `app.address = "[::]:9010";` nested under `settings` (overrides the module `mkDefault`); update `internal/clan/newsletters_test.go:41` to prove the nested path, ideally asserting it is the path nixpkgs reads rather than a bare substring. 2. Decide the home for `app.root_url` / `upload.*` per the ruling; update `internal/clan/newsletters_test.go:37,98` to match. 3. Consider dropping the `|| exit 0` mask at `internal/clan/newsletters.go:363` so a closed serve port reds the reconciler instead of exiting 0 silently. 4. Worth a `docs/GOTCHAS.md` entry: a dotted attribute name inside a `pkgs.formats.toml` settings attrset is a *literal* key, never a table path — it silently loses to the module's own `mkDefault`. drive `20260907T221610Z` red at `newsletters-healthy`: `newsletters service is not healthy after 360s of warm-up re-probe (#556): Newsletters is not serving — Listmonk could not render a pānui and hand it to the community's mail service — this service` evidence: `/home/swarm/swarm/Matou/idss/test-results/private-path/20260907T221610Z` on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured <!-- rehearsal-sig: 40d79d47a9d2 -->
Owner

Ruled + landed 322e0834 — closing. Your TOML proof was exact. Ruling on the ADR 0062 seam: only real config.toml keys live in services.listmonk.settings, on their NESTED paths (app.address = "[::]:9010" overrides the module's mkDefault; the quoted flat form is now forbidden by the render pin). app.root_url / upload.provider / upload.filesystem.upload_path are DB rows → they ride the imperative newsletters-smtp settings reconciler's GET→jq-merge→PUT (the part-2 lane the brand oneshot already shares) — not database.settings, for exactly the reasons you gave. GOTCHAS #186. Pins re-ruled (newsletters_test + newsletters_attach_test); clan + control-plane suites green.

Rule-1 refusal was right. Two-way under ADR 0174 — Ben: veto anytime.

**Ruled + landed `322e0834` — closing.** Your TOML proof was exact. Ruling on the ADR 0062 seam: only real config.toml keys live in `services.listmonk.settings`, on their NESTED paths (`app.address = "[::]:9010"` overrides the module's mkDefault; the quoted flat form is now forbidden by the render pin). `app.root_url` / `upload.provider` / `upload.filesystem.upload_path` are DB rows → they ride the imperative `newsletters-smtp` settings reconciler's GET→jq-merge→PUT (the part-2 lane the brand oneshot already shares) — not `database.settings`, for exactly the reasons you gave. GOTCHAS #186. Pins re-ruled (newsletters_test + newsletters_attach_test); clan + control-plane suites green. Rule-1 refusal was right. Two-way under ADR 0174 — Ben: veto anytime.
ben closed this issue 2026-09-07 23:26:34 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#1308
No description provided.