From 18c2a934b88fe33d59428bdf3874051e8f085234 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 19 Nov 2025 16:21:17 +1100 Subject: [PATCH] Better handling of an invalid config file (#10857) * Better handling of an invalid config file * Remove dud line --- src/backend/InvenTree/InvenTree/config.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/InvenTree/InvenTree/config.py b/src/backend/InvenTree/InvenTree/config.py index 07ba769879..0f0770ab1f 100644 --- a/src/backend/InvenTree/InvenTree/config.py +++ b/src/backend/InvenTree/InvenTree/config.py @@ -7,6 +7,7 @@ import os import random import shutil import string +import sys from pathlib import Path from typing import Optional @@ -195,7 +196,13 @@ def load_config_data(set_cache: bool = False) -> map | None: cfg_file = get_config_file() with open(cfg_file, encoding='utf-8') as cfg: - data = yaml.safe_load(cfg) + try: + data = yaml.safe_load(cfg) + except yaml.parser.ParserError as error: + logger.error( + "Error reading InvenTree configuration file '%s': %s", cfg_file, error + ) + sys.exit(1) # Set the cache if requested if set_cache: