Skip to content

[confmap/envprovider] Fix empty default resolving to nil instead of empty string#15131

Open
lazureykis wants to merge 1 commit intoopen-telemetry:mainfrom
lazureykis:fix/envprovider-empty-default
Open

[confmap/envprovider] Fix empty default resolving to nil instead of empty string#15131
lazureykis wants to merge 1 commit intoopen-telemetry:mainfrom
lazureykis:fix/envprovider-empty-default

Conversation

@lazureykis
Copy link
Copy Markdown

Description

When using ${env:VAR:-} with an unset variable, the empty default was
passed through YAML unmarshaling (NewRetrievedFromYAML), which converts
empty input to nil. This caused downstream validation failures in
components that distinguish between nil (unset) and "" (explicitly empty).

Skip YAML unmarshaling when the resolved value is an empty string from an
explicit default, returning "" directly via NewRetrieved.

Link to tracking issue

Fixes #14587

Testing

Added TestEmptyDefaultReturnsEmptyString verifying AsRaw() returns ""
for ${env:VAR:-} with an unset variable. All existing envprovider, confmap,
and e2e tests pass.

Documentation

No documentation changes needed.

…mpty string

When ${env:VAR:-} is used with an unset variable, the empty default
was passed through YAML unmarshaling which converts empty input to nil.
Skip YAML unmarshaling for this case, returning "" directly.

Fixes open-telemetry#14587

Assisted-by: Claude Opus 4.6
@lazureykis lazureykis marked this pull request as ready for review April 16, 2026 15:14
@lazureykis lazureykis requested a review from a team as a code owner April 16, 2026 15:14
@lazureykis lazureykis requested a review from codeboten April 16, 2026 15:14
@github-actions github-actions Bot requested review from evan-bradley and mx-psi April 16, 2026 15:15
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.25%. Comparing base (307e3ab) to head (cd44d0d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15131      +/-   ##
==========================================
+ Coverage   91.24%   91.25%   +0.01%     
==========================================
  Files         699      699              
  Lines       44913    44915       +2     
==========================================
+ Hits        40979    40987       +8     
+ Misses       2786     2782       -4     
+ Partials     1148     1146       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

${env:VAR:-} with empty default resolves to nil instead of empty string, causing downstream validation failures

1 participant