A config file pixa cannot read is skipped silently instead of aborting startup #176

Open
opened 2026-10-04 09:25:03 +02:00 by clawbot · 1 comment
Collaborator

Found by the review of #174 (#174 (comment)).

When no config path is given, the config loader in internal/config/config.go tries /etc/pixa/config.yml (and .yaml), ~/.config/pixa/config.yml (and .yaml), then config.yml and config.yaml in the working directory. For each it calls os.Stat and moves on to the next place whenever that returns any error, not only when the file does not exist. So a config file pixa is not allowed to read (for example /etc/pixa open only to root while pixa runs as another user) is passed over without a word, and pixa starts on a later file or on the environment and defaults: another signing key, another state directory, the defaults for every limit. A file that exists but does not parse already aborts startup; a file that exists but cannot be read should too.

Plan:

  • Only a "does not exist" error (errors.Is(err, fs.ErrNotExist)) moves on to the next place; any other error from os.Stat aborts startup naming the path and the error, like a file that does not parse.
  • Test first: a config file in a directory the process cannot enter aborts startup with an error naming the path (skipped when the test runs as root, where permissions do not apply).
  • README.md, where it describes the search order, says a file that is there but cannot be read aborts startup.

Model: opus-5-5

Found by the review of https://git.eeqj.de/sneak/pixa/pulls/174 (https://git.eeqj.de/sneak/pixa/pulls/174#issuecomment-121510). When no config path is given, the config loader in `internal/config/config.go` tries `/etc/pixa/config.yml` (and `.yaml`), `~/.config/pixa/config.yml` (and `.yaml`), then `config.yml` and `config.yaml` in the working directory. For each it calls `os.Stat` and moves on to the next place whenever that returns any error, not only when the file does not exist. So a config file pixa is not allowed to read (for example `/etc/pixa` open only to root while pixa runs as another user) is passed over without a word, and pixa starts on a later file or on the environment and defaults: another signing key, another state directory, the defaults for every limit. A file that exists but does not parse already aborts startup; a file that exists but cannot be read should too. Plan: - Only a "does not exist" error (`errors.Is(err, fs.ErrNotExist)`) moves on to the next place; any other error from `os.Stat` aborts startup naming the path and the error, like a file that does not parse. - Test first: a config file in a directory the process cannot enter aborts startup with an error naming the path (skipped when the test runs as root, where permissions do not apply). - `README.md`, where it describes the search order, says a file that is there but cannot be read aborts startup. Model: opus-5-5
Author
Collaborator

Built in #181, per the plan: of the places pixa looks for its config file on its own, only one where the file does not exist is passed over; any other error, such as a directory pixa may not enter, aborts startup naming the file.

Model: opus-5-5

Built in https://git.eeqj.de/sneak/pixa/pulls/181, per the plan: of the places pixa looks for its config file on its own, only one where the file does not exist is passed over; any other error, such as a directory pixa may not enter, aborts startup naming the file. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/pixa#176