Skip to content

Add strict YAML parsing to reject unknown fields#608

Open
AdeshGhadage wants to merge 1 commit intoprometheus:masterfrom
AdeshGhadage:feature/strict-yaml-parsing
Open

Add strict YAML parsing to reject unknown fields#608
AdeshGhadage wants to merge 1 commit intoprometheus:masterfrom
AdeshGhadage:feature/strict-yaml-parsing

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, good idea, we can do some cleanup!

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.

3 participants