Skip to content

Commit 81e2de2

Browse files
jangjangjimy-ship-it
authored andcommitted
Update logfilter.py
- Add buffer.seek(0) after truncate to reset file pointer position - Add isinstance and len check before accessing item[16] to prevent IndexError - Improves robustness when processing malformed CSV log entries
1 parent e51dd08 commit 81e2de2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

gpMgmt/bin/gppylib/logfilter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,17 @@ def __next__(self):
278278
item = next(self.source)
279279
#we need to make a minor format change to the log level field so that
280280
# our single regex will match both.
281-
item[16] = item[16] + ": "
281+
# Check if item has enough columns before accessing index 16
282+
if isinstance(item, list) and len(item) > 16:
283+
item[16] = item[16] + ": "
282284

283285
self.buffer.truncate(0)
286+
self.buffer.seek(0)
284287
self.writer.writerow(item)
285288

286289
return self.buffer.getvalue()
287290

291+
288292
#------------------------------- Spying --------------------------------
289293

290294
class Count(object):

0 commit comments

Comments
 (0)