-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[confmap] Embedded structs fail to unmarshal #12709
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
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Probably the easiest solution is to disallow "embedded" structs that are not "squashed", but would be good for someone to think about this. |
This PR: * Helps with #12709, to avoid the situation where we need to add Unmarshal for a struct and if used as embedded will not work. * Helps with avoiding name conflicts between variables. Will allow for example to have a "Timeout" member in both QueueConfig and ClientConfig, even though that was a valid YAML config since `QueueConfig` is under "seding_queue". * This is a breaking change only if devs are created manually the OTLP configs which should be very rare, and unfortunately this is hard to do using deprecation steps. Signed-off-by: Bogdan Drutu <[email protected]>
I ran into this issue myself when trying to upgrade to 0.123.0 It seems that using an embedded struct also brings in all of its implementations, so This was surprising to me as someone who isn't a go expert. |
Not sure if it's the same issue but I found the error message quite misleading: Consider this simple test
Test config
This used to work fine until v0.123.0. In v0.123.0 the above returns an error:
...but the issue has nothing to do with timeout, the fix is instead to move QueueConfig to a dedicated sub-section like
This should be an API breaking change, though I cannot find any reference in the changelog |
In the example above if you squash the embedded struct, it leads to an unmarshal error. |
Component(s)
confmap
What happened?
Now, if we define the "Unmarshal" on "FooConfig" we will get an error that
encoding
is not defined. This is a problem that will stop development for FooConfig.Collector version
v0.122.0
The text was updated successfully, but these errors were encountered: