Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loosely defined behavior when parsing unset environment variables #3864

Closed
joaopgrassi opened this issue Feb 7, 2024 · 3 comments
Closed
Assignees
Labels
area:configuration Related to configuring the SDK area:sdk Related to the SDK [label deprecated] triaged-needmoreinfo [label deprecated] The issue is triaged - the OTel community needs more information to decide spec:miscellaneous For issues that don't match any other spec label spec:resource Related to the specification/resource directory

Comments

@joaopgrassi
Copy link
Member

joaopgrassi commented Feb 7, 2024

The Parsing empty value SDK env variables specification, says that env variables with empty values should be interpreted the same way as unset:

The SDK MUST interpret an empty value of an environment variable the same way as when the variable is unset.

But I couldn't find any similar specification defining the behavior for interpreting unset env variables.

Additional context.

The question came up when adding the env resource detector to Envoy proxy. Initially, the detector was throwing an exception when the variable was unset/empty (which the Envoy community initially thought that was the best way forward). Now revisiting this decision, we want to prevent the detector throwing errors, as it impacts things like service meshes (e.g., Istio)

Then, a question in the PR came: if the env variable is set, but empty it should still throw an error. Then pointing to the spec section above makes it unclear what it should be done, since there's no definition for unset.

What did you expect to see?

It seems all SDKs I looked, don't throw errors when the env variable is unset, which makes sense. Then this makes unset/empty the same thing. IMO this should be also written to the spec to avoid any confusion.

@joaopgrassi joaopgrassi added the spec:resource Related to the specification/resource directory label Feb 7, 2024
@arminru arminru added area:sdk Related to the SDK spec:miscellaneous For issues that don't match any other spec label area:configuration Related to configuring the SDK labels Feb 7, 2024
@jack-berg jack-berg added the [label deprecated] triaged-needmoreinfo [label deprecated] The issue is triaged - the OTel community needs more information to decide label Feb 14, 2024
@jack-berg
Copy link
Member

Then pointing to the spec section above makes it unclear what it should be done, since there's no definition for unset.

The definition for empty is presumably runtime dependent. A runtime might return null, nil, an empty string "", or some other equivalent when an environment variable is unset.

Are you looking to have this codified, or something else?

@jack-berg
Copy link
Member

Closing. @joaopgrassi please re-open if you think some additional clarity is needed in the spec.

@joaopgrassi
Copy link
Member Author

joaopgrassi commented Apr 30, 2024

@jack-berg Sorry I missed this somehow.

The definition for empty is presumably runtime dependent. A runtime might return null, nil, an empty string "", or some other equivalent when an environment variable is unset.

Yeah that makes sense. It is just lacking what it should be done/behavior when any of these happen. Should it throw. should it log error etc. Because "empty" refers that it should behave the same as unset but we never tell what is the behavior of unset.

I think it can create different behaviors and probably best if it's clarified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:configuration Related to configuring the SDK area:sdk Related to the SDK [label deprecated] triaged-needmoreinfo [label deprecated] The issue is triaged - the OTel community needs more information to decide spec:miscellaneous For issues that don't match any other spec label spec:resource Related to the specification/resource directory
Projects
None yet
Development

No branches or pull requests

4 participants