Port is not overridable with the PORT environment variable #99

Open
opened 2026-08-09 07:04:27 +02:00 by clawbot · 0 comments
Collaborator

From the audit against the canonical REPO_POLICIES.md, verified against main at 61f42e6.

The policy states:

> Dockerized web services listen on port 8080 by default, overridable with PORT.

The default half is correct: DefaultPort = 8080 (internal/config/config.go:23) and EXPOSE 8080 (Dockerfile:76). The override half does not exist. config.go:104 reads Port: loader.intVal("port", DefaultPort) — YAML file only. A grep for Getenv across internal/ and cmd/ returns exactly three hits, all in config.go: PIXA_CONFIG_PATH (line 340) and HOME twice (lines 355-356). There is no PORT handling anywhere.

This bites in exactly the deployment the policy is written for. Dockerfile:78's ENTRYPOINT hardcodes --config /etc/pixa/config.yml, so changing the listen port in a container today means bind-mounting a whole replacement config file — for one integer. Container platforms conventionally inject PORT, and this is a prerequisite for a clean uPaaS deployment (#17).

Definition of done

  1. PORT overrides the config-file value and the default. Precedence documented explicitly (suggest: PORT env > config file > default, so the platform can always win).
  2. An unparseable PORT must abort startup naming the variable and the offending value. Repo policy is explicit that a set-but-invalid explicit value never silently falls back to a default — PORT=banana must not quietly become 8080. Use the same strict-parsing pattern as the config getters.
  3. Range validation matches whatever the config file path already enforces, so the two entry points cannot disagree about what a valid port is.
  4. Decide whether other keys deserve the same treatment or whether PORT is a deliberate special case (the policy names only PORT). Note the env: section that smartconfig already provides is a related but different mechanism — see #75, which documents it. Say in the PR how the two interact, so operators are not left guessing which wins.
  5. Failing tests first: PORT=9090 takes effect over a config file specifying 8080; PORT=banana exits non-zero naming the variable; absent PORT leaves existing behavior unchanged.
  6. README.md and config.example.yml document the override. make check green.

Coordination

Touches internal/config/config.go, which PR #54 conflicts with heavily (it rewrote that file for lint conformance after absorbing #53). Do after #54 merges.

From the audit against the canonical `REPO_POLICIES.md`, verified against `main` at `61f42e6`. The policy states: > Dockerized web services listen on port 8080 by default, overridable with `PORT`. The default half is correct: `DefaultPort = 8080` (`internal/config/config.go:23`) and `EXPOSE 8080` (`Dockerfile:76`). The override half does not exist. `config.go:104` reads `Port: loader.intVal("port", DefaultPort)` — YAML file only. A grep for `Getenv` across `internal/` and `cmd/` returns exactly three hits, all in `config.go`: `PIXA_CONFIG_PATH` (line 340) and `HOME` twice (lines 355-356). There is no `PORT` handling anywhere. This bites in exactly the deployment the policy is written for. `Dockerfile:78`'s `ENTRYPOINT` hardcodes `--config /etc/pixa/config.yml`, so changing the listen port in a container today means bind-mounting a whole replacement config file — for one integer. Container platforms conventionally inject `PORT`, and this is a prerequisite for a clean uPaaS deployment (#17). ## Definition of done 1. `PORT` overrides the config-file value and the default. Precedence documented explicitly (suggest: `PORT` env > config file > default, so the platform can always win). 2. **An unparseable `PORT` must abort startup** naming the variable and the offending value. Repo policy is explicit that a set-but-invalid explicit value never silently falls back to a default — `PORT=banana` must not quietly become 8080. Use the same strict-parsing pattern as the config getters. 3. Range validation matches whatever the config file path already enforces, so the two entry points cannot disagree about what a valid port is. 4. Decide whether other keys deserve the same treatment or whether `PORT` is a deliberate special case (the policy names only `PORT`). Note the `env:` section that smartconfig already provides is a related but different mechanism — see #75, which documents it. Say in the PR how the two interact, so operators are not left guessing which wins. 5. Failing tests first: `PORT=9090` takes effect over a config file specifying 8080; `PORT=banana` exits non-zero naming the variable; absent `PORT` leaves existing behavior unchanged. 6. `README.md` and `config.example.yml` document the override. `make check` green. ## Coordination Touches `internal/config/config.go`, which PR #54 conflicts with heavily (it rewrote that file for lint conformance after absorbing #53). Do **after** #54 merges.
clawbot added this to the 1.0.0 milestone 2026-08-09 07:04:27 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/pixa#99