Commit 738e024
authored
Handle null bot name correctly when trying to find region in monitoring (#4592)
This fixes the following error in app engine crons:
```
Failed to flush metrics: expected string or bytes-like object, got 'NoneType'
Traceback (most recent call last):
File "/layers/google.python.runtime/python/lib/python3.11/threading.py", line 1002, in _bootstrap
self._bootstrap_inner()
File "/layers/google.python.runtime/python/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
self.run()
File "/layers/google.python.runtime/python/lib/python3.11/threading.py", line 982, in run
self._target(*self._args, **self._kwargs)
File "/srv/clusterfuzz/_internal/metrics/monitor.py", line 171, in _flush_loop
self._flush_function()
File "/srv/clusterfuzz/_internal/metrics/monitor.py", line 134, in _flush_metrics
logs.error(f'Failed to flush metrics: {e}')
LogError: Failed to flush metrics: expected string or bytes-like object, got 'NoneType'
Traceback (most recent call last):
File "/srv/clusterfuzz/_internal/metrics/monitor.py", line 118, in _flush_metrics
metric.monitoring_v3_time_series(series, labels, start_time, end_time,
File "/srv/clusterfuzz/_internal/metrics/monitor.py", line 343, in monitoring_v3_time_series
self.monitoring_v3_metric(time_series.metric, labels)
File "/srv/clusterfuzz/_internal/metrics/monitor.py", line 321, in monitoring_v3_metric
metric.labels['region'] = _get_region(bot_name)
^^^^^^^^^^^^^^^^^^^^^
File "/srv/clusterfuzz/_internal/metrics/monitor.py", line 637, in _get_region
if re.match(pattern['pattern'], bot_name):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.runtime/python/lib/python3.11/re/__init__.py", line 166, in match
return _compile(pattern, flags).match(string)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'
```1 parent 4c364a1 commit 738e024
2 files changed
+6
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
496 | | - | |
497 | | - | |
| 496 | + | |
498 | 497 | | |
499 | 498 | | |
500 | 499 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
316 | | - | |
317 | | - | |
318 | | - | |
| 316 | + | |
| 317 | + | |
319 | 318 | | |
320 | 319 | | |
321 | 320 | | |
| |||
625 | 624 | | |
626 | 625 | | |
627 | 626 | | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
628 | 630 | | |
629 | 631 | | |
630 | 632 | | |
| |||
0 commit comments