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

config: Handle null attributes as invalid #6645

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mikeblum
Copy link

@mikeblum mikeblum commented Jan 18, 2025

Fixes #6629

@mikeblum
Copy link
Author

mikeblum commented Jan 18, 2025

As written the omitempty is allowing the YAML to parse without an error. Added a validate_config test to factor out the yaml:omitempty issue. Should we remove the omitempty annotations to catch these sorts of issues and check for null / empty after yaml.parse or is there another way?

I could see the matrix of property checks growing quite a bit as new properties get added over time - we'd need a check for each attribute or go down the reflect route which has it's own set of issues.

https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/config/v0.3.0/generated_config.go#L427

@pellared pellared changed the title [GH-6629] config: Handle null attributes as invalid config: Handle null attributes as invalid Jan 20, 2025
@pellared
Copy link
Member

@mikeblum, I think that you need to implement func (j *AttributeNameValue) UnmarshalYAML(unmarshal func(interface{}) error) error and func (j *AttributeNameValue) MarshalJSON() ([]byte, error) methods. Look at config_json.go and config_yaml.go for examples.

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.

config: Handle null attributes as invalid
2 participants