8000 openmetrics: Throw error on blank line (#576) · lweith/client_python@3627472 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3627472

Browse files
authored
openmetrics: Throw error on blank line (prometheus#576)
As per current spec draft blank lines are not allowed Signed-off-by: Manuel Rüger <manuel@rueg.eu>
1 parent 5b0a476 commit 3627472

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

prometheus_client/openmetrics/parser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,9 @@ def build_metric(name, documentation, typ, unit, samples):
482482
if eof:
483483
raise ValueError("Received line after # EOF: " + line)
484484

485+
if not line:
486+
raise ValueError("Received blank line")
487+
485488
if line == '# EOF':
486489
eof = True
487490
elif line.startswith('#'):

tests/openmetrics/test_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,8 @@ def test_invalid_input(self):
598598
for case in [
599599
# No EOF.
600600
(''),
601+
# Blank line
602+
('a 1\n\n# EOF\n'),
601603
# Text after EOF.
602604
('a 1\n# EOF\nblah'),
603605
('a 1\n# EOFblah'),

0 commit comments

Comments
 (0)
0