Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4535ce0

Browse filesBrowse files
authored
Add sanity check for label value (#1012)
Signed-off-by: Pengfei Zhang <andysim3d@gmail.com>
1 parent 7a80f00 commit 4535ce0
Copy full SHA for 4535ce0

File tree

Expand file treeCollapse file tree

2 files changed

+3
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+3
-0
lines changed

‎prometheus_client/metrics.py

Copy file name to clipboardExpand all lines: prometheus_client/metrics.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,8 @@ def info(self, val: Dict[str, str]) -> None:
705705
if self._labelname_set.intersection(val.keys()):
706706
raise ValueError('Overlapping labels for Info metric, metric: {} child: {}'.format(
707707
self._labelnames, val))
708+
if any(i is None for i in val.values()):
709+
raise ValueError('Label value cannot be None')
708710
with self._lock:
709711
self._value = dict(val)
710712

‎tests/test_core.py

Copy file name to clipboardExpand all lines: tests/test_core.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ def test_info(self):
534534

535535
def test_labels(self):
536536
self.assertRaises(ValueError, self.labels.labels('a').info, {'l': ''})
537+
self.assertRaises(ValueError, self.labels.labels('a').info, {'il': None})
537538

538539
self.labels.labels('a').info({'foo': 'bar'})
539540
self.assertEqual(1, self.registry.get_sample_value('il_info', {'l': 'a', 'foo': 'bar'}))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.