mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-11 22:07:27 -08: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() {
|
if !model.LabelName(l.Name).IsValid() {
|
||||||
return fmt.Errorf("%q is not a valid label name", l.Name)
|
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
|
// First set the correct scrape interval, then check that the timeout
|
||||||
|
|
|
@ -714,6 +714,9 @@ var expectedErrors = []struct {
|
||||||
}, {
|
}, {
|
||||||
filename: "labelname2.bad.yml",
|
filename: "labelname2.bad.yml",
|
||||||
errMsg: `"not:allowed" is not a valid label name`,
|
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",
|
filename: "regex.bad.yml",
|
||||||
errMsg: "error parsing regexp",
|
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 a new issue