Skip to content

Commit

Permalink
[configuration] Fail on unsupported identifiers (#4002)
Browse files Browse the repository at this point in the history
  • Loading branch information
mx-psi authored Apr 30, 2024
1 parent 7d7b8fa commit 6f4fd8d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ release.

- Clarify syntax for environment variable substitution regular expression
([#4001](https://github.com/open-telemetry/opentelemetry-specification/pull/4001))
- Error out on invalid identifiers in environment variable substitution.
([#4002](https://github.com/open-telemetry/opentelemetry-specification/pull/4002))

### Common

Expand Down
10 changes: 10 additions & 0 deletions specification/configuration/file-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ more non line break characters (i.e. any character except `\n`). If a referenced
environment variable is not defined and does not have a `DEFAULT_VALUE`, it MUST
be replaced with an empty value.

When parsing a configuration file that contains a reference not matching
the references regular expression but does match the following PCRE2
regular expression, the parser MUST return an empty result (no partial
results are allowed) and an error describing the parse failure to the user.

```regexp
\$\{(?<INVALID_IDENTIFIER>[^}]+)\}
```

Node types MUST be interpreted after environment variable substitution takes
place. This ensures the environment string representation of boolean, integer,
or floating point fields can be properly converted to expected types.
Expand Down Expand Up @@ -125,6 +134,7 @@ string_key_with_default: ${UNDEFINED_KEY:-fallback} # UNDEFINED_KEY is not def
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
# invalid_identifier_key: ${STRING_VALUE:?error} # If uncommented, this is an invalid identifier, it would fail to parse
```

Environment variable substitution results in the following YAML:
Expand Down

0 comments on commit 6f4fd8d

Please sign in to comment.