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

Add strict YAML parsing to reject unknown fields #608

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AdeshGhadage
Copy link

This pull request introduces strict YAML parsing for configuration files #546 . I am new to Prometheus. Please correct me if I misunderstand the issue.

Signed-off-by: AdeshGhadage <adeshghadage9@gmail.com>
@AdeshGhadage AdeshGhadage force-pushed the feature/strict-yaml-parsing branch from 11e60c8 to 207d1a6 Compare January 15, 2025 06:09
@pedro-stanaka
Copy link
Contributor

I believe you could use yaml.UnmarshalStrict instead of doing all of this by hand.

Comment on lines +87 to +91
validFields := []string{
"match", "name", "labels", "honor_labels", "observer_type", "legacy_buckets",
"legacy_quantiles", "match_type", "help", "action", "match_metric_type", "ttl",
"summary_options", "histogram_options", "scale",
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This will cause some burden to update the structs. We can use yaml.UnmarshalStrict. Also, @matthiasr what do you think of dropping those deprecated fields? They have been here a while.

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.

2 participants