mirror of
https://github.com/prometheus/prometheus
synced 2024-12-24 23:42:32 +00:00
Check if label value is valid when unmarhsaling external labels from
YAML, add a test to config_tests for valid/invalid external label value. Signed-off-by: Callum Styan <callumstyan@gmail.com>
This commit is contained in:
parent
807fd33ecc
commit
5603b857a9
@ -304,6 +304,9 @@ func (c *GlobalConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
if !model.LabelName(l.Name).IsValid() {
|
||||
return fmt.Errorf("%q is not a valid label name", l.Name)
|
||||
}
|
||||
if !model.LabelValue(l.Value).IsValid() {
|
||||
return fmt.Errorf("%q is not a valid label value", l.Value)
|
||||
}
|
||||
}
|
||||
|
||||
// First set the correct scrape interval, then check that the timeout
|
||||
|
@ -714,6 +714,9 @@ var expectedErrors = []struct {
|
||||
}, {
|
||||
filename: "labelname2.bad.yml",
|
||||
errMsg: `"not:allowed" is not a valid label name`,
|
||||
}, {
|
||||
filename: "labelvalue.bad.yml",
|
||||
errMsg: `"\xff" is not a valid label value`,
|
||||
}, {
|
||||
filename: "regex.bad.yml",
|
||||
errMsg: "error parsing regexp",
|
||||
|
3
config/testdata/labelvalue.bad.yml
vendored
Normal file
3
config/testdata/labelvalue.bad.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
global:
|
||||
external_labels:
|
||||
name: !!binary "/w=="
|
Loading…
Reference in New Issue
Block a user