Skip to content

Substitute empty for unset config env vars without defaults#5408

Open
ocelotl wants to merge 1 commit into
open-telemetry:mainfrom
ocelotl:issue_5405_unset_env_var_empty_value
Open

Substitute empty for unset config env vars without defaults#5408
ocelotl wants to merge 1 commit into
open-telemetry:mainfrom
ocelotl:issue_5405_unset_env_var_empty_value

Conversation

@ocelotl

@ocelotl ocelotl commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #5405.

Declarative config environment variable substitution rejected any ${VAR} reference to an unset variable that had no default, raising a ConfigurationError and preventing SDK initialization:

Environment variable substitution failed: Environment variable 'OTEL_EXPORTER_OTLP_HEADERS' not found and no default provided

The declarative configuration spec requires an unset variable without a default to be replaced with an empty value (which the YAML parser then interprets as null). This matches the Java and Node.js implementations and lets configuration files be shared across languages.

Changes

  • opentelemetry-configuration: an unset ${VAR} with no default now substitutes an empty value instead of raising.
  • Removed the now-unused EnvSubstitutionError (its only raise site is gone) from the module and the file package's public exports.
  • Updated the substitution and loader tests to assert the empty/null behavior; ${ENV:-production} still applies its default.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • opentelemetry-configuration test suite (363 passed, 5 subtests).
  • ruff check and ruff format --check clean on the changed files.

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelog has been updated
  • Unit tests have been added
  • Documentation has been updated

@ocelotl
ocelotl marked this pull request as ready for review July 13, 2026 02:04
@ocelotl
ocelotl requested a review from a team as a code owner July 13, 2026 02:04
@ocelotl
ocelotl force-pushed the issue_5405_unset_env_var_empty_value branch from c108bb7 to 9697dea Compare July 13, 2026 02:33

@MikeGoldsmith MikeGoldsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Left one comment regarding allowing empty substitute values which we'll need to resolve.

@github-project-automation github-project-automation Bot moved this to Reviewed PRs that need fixes in Python PR digest Jul 13, 2026
@ocelotl
ocelotl requested a review from MikeGoldsmith July 16, 2026 02:41
Declarative config environment variable substitution rejected any
${VAR} reference to an unset variable that had no default, raising a
ConfigurationError and preventing SDK initialization. The declarative
configuration spec requires an unset variable without a default to be
replaced with an empty value (which YAML then reads as null), matching
the Java and Node.js implementations and allowing config files to be
shared across languages.

Replace the raise with empty substitution. EnvSubstitutionError is kept
as public API for backward compatibility but is no longer raised.
Update tests accordingly.

Fixes open-telemetry#5405
@ocelotl
ocelotl force-pushed the issue_5405_unset_env_var_empty_value branch from 1aa11c5 to 0700cf7 Compare July 16, 2026 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Reviewed PRs that need fixes

Development

Successfully merging this pull request may close these issues.

Declarative config env substitution rejects unset variables without defaults

3 participants