Skip to content

fix(configuration): improve environment variable substitution to handle all the cases shown in the spec - #6757

Merged
trentm merged 6 commits into
open-telemetry:mainfrom
trentm:trentm-conf-substituteEnvVars
Jun 5, 2026
Merged

fix(configuration): improve environment variable substitution to handle all the cases shown in the spec#6757
trentm merged 6 commits into
open-telemetry:mainfrom
trentm:trentm-conf-substituteEnvVars

Conversation

@trentm

@trentm trentm commented May 22, 2026

Copy link
Copy Markdown
Contributor

https://opentelemetry.io/docs/specs/otel/configuration/data-model/#environment-variable-substitution
provides a number of test cases to exercise the algorithm expected
for environment variable substitution. This adds those test cases
and updates the processing to handle them all.

…le all the cases shown in the spec

https://opentelemetry.io/docs/specs/otel/configuration/data-model/#environment-variable-substitution
provides a number of test cases to exercise the algorithm expected
for environment variable substitution. This adds those test cases
and updates the processing to handle them all.
@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.82609% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 94.92%. Comparing base (8e4d4ed) to head (ddf8b6c).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
experimental/packages/configuration/src/utils.ts 97.61% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6757      +/-   ##
==========================================
- Coverage   94.92%   94.92%   -0.01%     
==========================================
  Files         377      377              
  Lines       12818    12827       +9     
  Branches     2924     2920       -4     
==========================================
+ Hits        12168    12176       +8     
- Misses        650      651       +1     
Files with missing lines Coverage Δ
...al/packages/configuration/src/FileConfigFactory.ts 98.16% <100.00%> (-0.27%) ⬇️
experimental/packages/configuration/src/utils.ts 97.43% <97.61%> (-0.61%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@trentm

trentm commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

Before this change, the env var substitution was failing these added tests:

    substituteEnvVars
      ✔ key: ${STRING_VALUE}
      ✔ key: ${BOOL_VALUE}
      ✔ key: ${INT_VALUE}
      ✔ key: ${FLOAT_VALUE}
      1) key: ${HEX_VALUE}
      ✔ key: "${STRING_VALUE}"
      2) key: "${BOOL_VALUE}"
      3) key: "${INT_VALUE}"
      4) key: "${FLOAT_VALUE}"
      ✔ key: "${HEX_VALUE}"
      ✔ key: "${env:STRING_VALUE}"
      ✔ key: "${INVALID_MAP_VALUE}"
      ✔ key: foo ${STRING_VALUE} ${FLOAT_VALUE}
      ✔ key: ${UNDEFINED_KEY}
      ✔ key: ${UNDEFINED_KEY:-fallback}
      ✔ ${STRING_VALUE}: value
      ✔ key: ${REPLACE_ME}
      ✔ key: ${UNDEFINED_KEY:-${STRING_VALUE}}
      5) key: ${STRING_VALUE:?error}
      ✔ key: $${STRING_VALUE}
      ✔ key: $$${STRING_VALUE}
      ✔ key: $$$${STRING_VALUE}
      ✔ key: $${STRING_VALUE:-fallback}
      ✔ key: $${STRING_VALUE:-${STRING_VALUE}}
      6) key: ${UNDEFINED_KEY:-$${UNDEFINED_KEY}}
      ✔ key: ${VALUE_WITH_ESCAPE}
      ✔ key: a $$ b
      ✔ key: a $ b

and others not in the set of examples in the spec, like FOO=TRUE (YAML allows a few capitalizations of bools),
other number forms (e.g. .1, 1e6, octal, etc.)

@trentm
trentm marked this pull request as ready for review May 22, 2026 22:54
@trentm
trentm requested a review from a team as a code owner May 22, 2026 22:54
Comment thread experimental/packages/configuration/src/utils.ts Outdated
Comment thread experimental/packages/configuration/test/utils.test.ts
@trentm
trentm requested a review from maryliag June 3, 2026 18:18
@trentm
trentm added this pull request to the merge queue Jun 5, 2026
Merged via the queue into open-telemetry:main with commit 3bd69ce Jun 5, 2026
31 of 32 checks passed
@trentm
trentm deleted the trentm-conf-substituteEnvVars branch June 5, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants