-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[confmap] Strings containing numbers in nonstandard notation are normalized to decimal notation #8565
Comments
Thanks for reporting this. This comes from the YAML library we use, a minimal example can be seen here: https://go.dev/play/p/eO1O_q2ITAU. It is documented on the README:
You don't need to be using the In your particular case, setting TEST to I asked upstream for a toggle on the library to avoid this quirk on go-yaml/yaml/issues/996. |
Ok, thanks for the clarification. I think it is a bit strange though that in the envprovider.go even use the yaml-parser to get environment variable values. |
Right, the processors:
transform: ${env:TRANSFORM_CONFIG} and pull in your full transform processor configuration from the Your issue though points to a general problem where our configuration loading system does not know it is mapping to a string and it loses the original representation of string values that can be interpreted as integers/floats. I wrote a small example here: https://go.dev/play/p/3gXGDllytzd, in summary with a config struct like: type Config struct {
Octal string
Hex string
Scientific string
Positive string
Infinite string
} a configuration like: Octal: 0123
Hex: 0xdeadbeef
Scientific: 1.23e5
Positive: +123
Infinite: .inf when loaded through loadedConfig := Config{
Octal: "83",
Hex: "3735928559",
Scientific: "123000",
Positive: "123",
Infinite: "+Inf",
} where even if the fields are |
Thanks for a great explanation! Since env is such a well established term I as a new user does not expect the support for yaml-parsing on my environment variables although i like the feature. Perhaps a solution could be suggested where we explicitly can call for the raw value of the environment variable? ${env:YAML_VALUE_OR_OTHER} ${env_raw:RAW_ENV_VALUE_NOT_RUN_THROUGH_YAML_PARSER} I've managed to work around it by adding the double quotes in the value so it is not critical for me. |
@rassmate If you use |
I think we can use something like this https://go.dev/play/p/g8hciqbI921 to fix this, but I want to first agree on how |
**Description:** Adds an RFC about how environment variable resolution should work **Link to tracking Issue:** Fixes #9515, relates to: - #8215 - #8565 - #9162 - #9531 - #9532 --------- Co-authored-by: Alex Boten <[email protected]> Co-authored-by: Evan Bradley <[email protected]>
**Description:** Adds an RFC about how environment variable resolution should work **Link to tracking Issue:** Fixes open-telemetry#9515, relates to: - open-telemetry#8215 - open-telemetry#8565 - open-telemetry#9162 - open-telemetry#9531 - open-telemetry#9532 --------- Co-authored-by: Alex Boten <[email protected]> Co-authored-by: Evan Bradley <[email protected]>
As part of the RFC we decided that @mx-psi what needs worked on for this issue? If there are reasonable work arounds, such as |
Sorry for ghosting you on this issue for a while but I like what I read and some thought is put in to this matter. Keep up the good work! |
@TylerHelmuth This will be solved by setting |
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description <!-- Issue number if applicable --> Adds tests of current type casting behavior when using env and file provider. #### Link to tracking issue Relates to #9854, #8565, #9532
#### Description <!-- Issue number if applicable --> - Add `confmap.strictlyTypedInput` feature gate that introduces stricter type checks when resolving configuration - Make `confmap.NewRetrievedFromYAML` function public so that external providers have consistent behavior when resolving YAML - Adds `confmap.Retrieved.AsString` method to retrieve string representation for retrieved values #### Link to tracking issue Relates to #9854, updates #8565, #9532
Describe the bug
When using the $env:ENVIRONMENT_VARIABLE_NAME syntax in the collector configuration a string with numbers only starting with zero is interpreted as a number.
Steps to reproduce
rassmate@855679d
What did you expect to see?
When working with environment variables I expected to get the exact value that the environment variable holds.
What did you see instead?
A string got interpreted into a number very different from the one in the environment variable when the value had a leading zero.
What version did you use?
v0.84
What config did you use?
Environment
OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")
Macbook air m2. Same error in openshift cluster
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: