Skip to content

Commit

Permalink
Clarify environment variable substitution is not recursive (#3913)
Browse files Browse the repository at this point in the history
Fixes #3894

## Changes

In the SDK file configuration, clarify environment variable substitution
is not recursive.
  • Loading branch information
marcalff authored Mar 29, 2024
1 parent 40aaf16 commit 1f48f59
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ release.

### SDK Configuration

- Clarify environment variable substitution is not recursive
([#3913](/~https://github.com/open-telemetry/opentelemetry-specification/pull/3913))

### Common

### Supplementary Guidelines
Expand Down
9 changes: 8 additions & 1 deletion specification/configuration/file-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ or floating point fields can be properly converted to expected types.
It MUST NOT be possible to inject YAML structures by environment variables. For
example, references to `INVALID_MAP_VALUE` environment variable below.

It MUST NOT be possible to inject environment variable by environment variables.
For example, references to `DO_NOT_REPLACE_ME` environment variable below.

For example, consider the following environment variables,
and [YAML](#yaml-file-format) configuration file:

Expand All @@ -102,7 +105,9 @@ export STRING_VALUE="value"
export BOOl_VALUE="true"
export INT_VALUE="1"
export FLOAT_VALUE="1.1"
export INVALID_MAP_VALUE"value\nkey:value" # An invalid attempt to inject a map key into the YAML
export INVALID_MAP_VALUE="value\nkey:value" # An invalid attempt to inject a map key into the YAML
export DO_NOT_REPLACE_ME="Never use this value" # An unused environment variable
export REPLACE_ME='${DO_NOT_REPLACE_ME}' # A valid replacement text, used verbatim, not replaced with "Never use this value"
```

```yaml
Expand All @@ -116,6 +121,7 @@ float_key: ${FLOAT_VALUE} # Valid reference to FLOAT
combo_string_key: foo ${STRING_VALUE} ${FLOAT_VALUE} # Valid reference to STRING_VALUE and FLOAT_VALUE
undefined_key: ${UNDEFINED_KEY} # Invalid reference, UNDEFINED_KEY is not defined and is replaced with ""
${STRING_VALUE}: value # Invalid reference, substitution is not valid in mapping keys and reference is ignored
recursive_key: ${REPLACE_ME} # Valid reference to REPLACE_ME
```
Environment variable substitution results in the following YAML:
Expand All @@ -131,6 +137,7 @@ float_key: 1.1 # Interpreted as type float, tag URI
combo_string_key: foo value 1.1 # Interpreted as type string, tag URI tag:yaml.org,2002:str
undefined_key: # Interpreted as type null, tag URI tag:yaml.org,2002:null
${STRING_VALUE}: value # Interpreted as type string, tag URI tag:yaml.org,2002:str
recursive_key: ${DO_NOT_REPLACE_ME} # Interpreted as type string, tag URI tag:yaml.org,2002:str
```
## SDK Configuration
Expand Down

0 comments on commit 1f48f59

Please sign in to comment.