From fdac8b855eff9c8d848ebb4f0ae0710001630f0c Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 17 Dec 2025 20:58:01 +0100 Subject: [PATCH] Fix: Strip whitespace from env vars before validation Pydantic cannot parse 'true ' (with trailing spaces) as boolean. Added field_validator to automatically strip whitespace from all string inputs. --- app/core/config.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/core/config.py b/app/core/config.py index 724f976..42d53c5 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -5,6 +5,7 @@ Handles environment variables and application settings import os from typing import List +from pydantic import field_validator from pydantic_settings import BaseSettings @@ -77,6 +78,14 @@ class Settings(BaseSettings): GITHUB_TOKEN: str = "" GITHUB_REPO: str = "ct/bmc_hub" + @field_validator('*', mode='before') + @classmethod + def strip_whitespace(cls, v): + """Strip leading/trailing whitespace from string values""" + if isinstance(v, str): + return v.strip() + return v + class Config: env_file = ".env" case_sensitive = True