Skip to content

Commit a838a30

Browse files
authored
Merge pull request #4766 from blozano-tt/fix-fixit-empty-stdin
Fix: Handle empty stdin gracefully in fixit command
2 parents 7cbc479 + 5affc8c commit a838a30

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • analyzer/codechecker_analyzer/cli

analyzer/codechecker_analyzer/cli/fixit.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,15 @@ def main(args):
377377
"arriving from standard input.")
378378
sys.exit(1)
379379

380-
try:
381-
reports = None if sys.stdin.isatty() else json.loads(sys.stdin.read())
382-
except json.decoder.JSONDecodeError as ex:
383-
LOG.error("JSON format error on standard input: %s", ex)
384-
sys.exit(1)
380+
reports = None
381+
if not sys.stdin.isatty():
382+
stdin_data = sys.stdin.read().strip()
383+
if stdin_data:
384+
try:
385+
reports = json.loads(stdin_data)
386+
except json.decoder.JSONDecodeError as ex:
387+
LOG.error("JSON format error on standard input: %s", ex)
388+
sys.exit(1)
385389

386390
# "CodeChecker fixit" can be applied on the output of
387391
# "CodeChecker cmd diff" command. Earlier this was a simple list of

0 commit comments

Comments
 (0)