billions-elephant-38030
02/28/2025, 2:18 PMMUTATORS_HEADER_CONFIG_HEADERS_X-USER="{{ print .Subject }}"
be failing with
The configuration contains values or keys which are invalid:
mutators.header: map[enabled:true]
^-- oneOf failed
The configuration contains values or keys which are invalid:
mutators.header.config: <nil>
^-- one or more required properties are missing
The configuration contains values or keys which are invalid:
mutators.header.enabled: true
^-- value must be false
brief-egg-61061
02/28/2025, 2:18 PMbrief-egg-61061
02/28/2025, 2:19 PMmutators.header.config
is <nil>
, which means it's missing or not properly set. 2. The configuration you're trying to set via the environment variable is for a specific header within the mutator's config, but the overall structure of the mutator configuration is not correct. To fix this issue, you need to properly structure the configuration for the header mutator. Here's how you can do it: 1. First, enable the header mutator: MUTATORS_HEADER_ENABLED=true
2. Then, set the configuration for the headers: MUTATORS_HEADER_CONFIG_HEADERS_X-USER="{{ print .Subject }}"
Make sure both of these environment variables are set correctly. The reason for the failure is that the configuration is expecting a specific structure, and setting just the header value without properly enabling and configuring the mutator causes these validation errors. For reference, here's how the configuration should look in the YAML format, as shown in the [Oathkeeper Mutator documentation](https://www.ory.sh/docs/oathkeeper/pipeline/mutator#header): yaml mutators: header: enabled: true config: headers: X-User: "{{ print .Subject }}"
When translating this to environment variables, you need to ensure all parts of this structure are represented. If you continue to face issues, you might want to double-check your overall Oathkeeper configuration and ensure that all necessary parts of the mutator configuration are properly set.billions-elephant-38030
02/28/2025, 2:19 PMMUTATORS_HEADER_ENABLED="true"
MUTATORS_HEADER_CONFIG_HEADERS_X-USER="{{ print .Subject }}"
billions-elephant-38030
02/28/2025, 2:20 PMMUTATORS_HEADER_ENABLED="true"
MUTATORS_HEADER_CONFIG_HEADERS_X-USER="{{ print .Subject }}"
brief-egg-61061
02/28/2025, 2:20 PMbrief-egg-61061
02/28/2025, 2:20 PMMUTATORS_HEADER_ENABLED=true MUTATORS_HEADER_CONFIG_HEADERS_X-USER={{ print .Subject }}
2. Configuration Precedence: Ory Oathkeeper uses a specific [configuration loading order](https://www.ory.sh/docs/oathkeeper/reference/configuration). Make sure that these environment variables are not being overridden by configuration files or other environment variables. 3. Version Compatibility: Ensure that you're using a version of Oathkeeper that supports this configuration method. Some older versions might have different requirements for setting up mutators. 4. Full Configuration: The error message suggests that the mutators.header.config
is <nil>
. This could indicate that other required configuration elements are missing. You might need to set additional configuration values for the header mutator. 5. Syntax in Docker Compose or Kubernetes: If you're using Docker Compose or Kubernetes, make sure the environment variables are properly escaped in your YAML files. 6. Logging and Debugging: Try running Oathkeeper with increased log verbosity to get more detailed error messages. This might provide more insight into why the configuration is not being recognized correctly. If none of these suggestions resolve the issue, it would be helpful to see your full Oathkeeper configuration (with sensitive information redacted) and the exact version of Oathkeeper you're using. This would allow for a more precise diagnosis of the problem. You might also want to consider opening an issue on the [Ory Oathkeeper GitHub repository](https://github.com/ory/oathkeeper) if you believe this might be a bug or an undocumented behavior.billions-elephant-38030
02/28/2025, 2:21 PMbillions-elephant-38030
02/28/2025, 2:21 PMbrief-egg-61061
02/28/2025, 2:21 PMbrief-egg-61061
02/28/2025, 2:21 PMbillions-elephant-38030
02/28/2025, 2:22 PMbrief-egg-61061
02/28/2025, 2:22 PMbrief-egg-61061
02/28/2025, 2:22 PMMUTATORS_HEADER_ENABLED=true MUTATORS_HEADER_CONFIG_HEADERS_X-USER="{{ print .Subject }}"
However, there are a few things to keep in mind: 1. Ensure that you're not mixing configuration methods. If you're using environment variables, make sure you're not also loading a config file that might override these settings. 2. Be careful with quoting and escaping, especially if you're setting these variables in a shell script or Docker/Kubernetes configuration. 3. For complex values (like JSON objects or arrays), you can use JSON strings. For example: MUTATORS_HEADER_CONFIG_HEADERS='{"X-User": "{{ print .Subject }}"}'
4. Remember that Oathkeeper uses a specific [configuration loading order](https://www.ory.sh/docs/oathkeeper/reference/configuration). Environment variables typically take precedence over config files, but it's good to be aware of this hierarchy. 5. If you're setting many configuration values, consider using an .env
file or a similar method to manage your environment variables more easily. If you're still encountering issues after setting these environment variables correctly, it might be helpful to: 1. Double-check that the environment variables are actually being set and picked up by the Oathkeeper process. 2. Run Oathkeeper with increased verbosity to see how it's interpreting your configuration. 3. Ensure you're using a recent version of Oathkeeper that fully supports environment variable configuration. If problems persist, consider sharing more details about your setup and the specific error messages you're seeing with the Ory community through their [GitHub issues](https://github.com/ory/oathkeeper/issues) or [Community Slack](https://slack.ory.sh).