Skip to content

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

Open
lazureykis wants to merge 2 commits 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 2 commits 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.29%. Comparing base (98f555d) to head (cebdf58).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15131      +/-   ##
==========================================
+ Coverage   90.38%   91.29%   +0.91%     
==========================================
  Files         702      702              
  Lines       54097    45255    -8842     
==========================================
- Hits        48893    41315    -7578     
+ Misses       4054     2787    -1267     
- Partials     1150     1153       +3     

☔ 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.

@lazureykis
Copy link
Copy Markdown
Author

@codeboten could you take a look please?

@codspeed-hq

This comment was marked as resolved.

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