Skip to content

payjoin-mailroom silently ignores unknown config keys #2084

Backlog

Description

@AdityaKaushal17

While reviewing #2037, I misspelled extra_allowed_purposes in the test's TOML. The config loaded without an error, and the relay then rejected the purpose (404). The setting was silently dropped.

Config, V1Config, OhttpRelayConfig and AccessControlConfig in payjoin-mailroom/src/config.rs use #[serde(default)] without deny_unknown_fields, so any misspelled key falls back to its default. For ohttp_relay, that means the relay forwards a different set of purposes from what the operator configured.

I tried adding #[serde(deny_unknown_fields)] to these structs. Typos are then rejected, but two side effects came up:

  1. Env vars use the same deserializer, so any unrelated PJ_* variable (for example PJ_UNRELATED_THING=1) stops startup with unknown field 'unrelated_thing'.
  2. A section for a feature that isn't compiled in (for example [acme] without the acme feature) is also rejected.

Possible directions:

  • (a) Hard error for unknown keys from the config file only, with env vars kept lenient.
  • (b) Log a warning for unknown keys instead of failing.
  • (c) Hard error everywhere, and document it.

Which would you prefer? I'd like to work on this.

AI disclosure: I found the original typo behaviour myself while reviewing #2037. Claude ran the two side-effect checks, and I'll rerun everything locally before opening a PR.

Activity

  1. xstoicunicornx commented on Dec 2, 2026

    @xstoicunicornx
    Collaborator

    I happened to come across this in last few days and was leaning towards allowing unknown fields, just so a config doesn't need to be updated if you turn off a previously configured feature (like telemetry).

    I didn't think about/look into the warning option though, how would that be implemented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions