File tree 2 files changed +8
-1
lines changed
prometheus_client/openmetrics 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,10 @@ def _parse_timestamp(timestamp):
75
75
return core .Timestamp (int (parts [0 ]), int (parts [1 ][:9 ].ljust (9 , "0" )))
76
76
except ValueError :
77
77
# Float.
78
- return float (timestamp )
78
+ ts = float (timestamp )
79
+ if math .isnan (ts ) or math .isinf (ts ):
80
+ raise ValueError ("Invalid timestamp: {0!r}" .format (timestamp ))
81
+ return ts
79
82
80
83
81
84
def _parse_labels (it , text ):
Original file line number Diff line number Diff line change @@ -477,6 +477,10 @@ def test_invalid_input(self):
477
477
('a 1 z\n # EOF\n ' ),
478
478
('a 1 1z\n # EOF\n ' ),
479
479
('a 1 1.1.1\n # EOF\n ' ),
480
+ ('a 1 NaN\n # EOF\n ' ),
481
+ ('a 1 Inf\n # EOF\n ' ),
482
+ ('a 1 +Inf\n # EOF\n ' ),
483
+ ('a 1 -Inf\n # EOF\n ' ),
480
484
# Bad exemplars.
481
485
('# TYPE a histogram\n a_bucket{le="+Inf"} 1 #\n # EOF\n ' ),
482
486
('# TYPE a histogram\n a_bucket{le="+Inf"} 1# {} 1\n # EOF\n ' ),
You can’t perform that action at this time.
0 commit comments