From 82106cf636dbd536f53ef247815f96838494d240 Mon Sep 17 00:00:00 2001 From: Floke Date: Sat, 3 Jan 2026 09:06:00 +0000 Subject: [PATCH] fix(debug): Add version info and API key debugging - Adds a version and timestamp to the orchestrator's startup logs to verify code deployment. - Introduces extensive debug logging in config.py and helpers.py to trace the API key loading process, including exact file paths and environment variable checks. This will help diagnose the persistent 'API Key missing' error. --- config.py | 1 + gtm_architect_orchestrator.py | 3 ++- helpers.py | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index e607f9d9..46b4c17a 100644 --- a/config.py +++ b/config.py @@ -490,6 +490,7 @@ class Config: """Laedt API-Schluessel aus den definierten Dateien.""" logger = logging.getLogger(__name__) logger.info("Lade API-Schluessel...") + print(f"DEBUG: Attempting to load API keys. BASE_DIR: {BASE_DIR}") # Debug print cls.API_KEYS['openai'] = cls._load_key_from_file(API_KEY_FILE) cls.API_KEYS['serpapi'] = cls._load_key_from_file(SERP_API_KEY_FILE) cls.API_KEYS['genderize'] = cls._load_key_from_file(GENDERIZE_API_KEY_FILE) diff --git a/gtm_architect_orchestrator.py b/gtm_architect_orchestrator.py index 5435992a..5513e784 100644 --- a/gtm_architect_orchestrator.py +++ b/gtm_architect_orchestrator.py @@ -20,6 +20,7 @@ LOG_DIR = "Log_from_docker" if not os.path.exists(LOG_DIR): os.makedirs(LOG_DIR) +ORCHESTRATOR_VERSION = "1.1.0" run_timestamp = datetime.now().strftime("%y-%m-%d_%H-%M-%S") log_file_path = os.path.join(LOG_DIR, f"{run_timestamp}_gtm_orchestrator_run.log") @@ -31,7 +32,7 @@ logging.basicConfig( logging.StreamHandler(sys.stdout) ] ) - +logging.info(f"GTM Architect Orchestrator v{{ORCHESTRATOR_VERSION}} ({{run_timestamp}}) starting...") def log_and_save(project_id, step_name, data_type, content): logging.info(f"Project {project_id} - Step: {step_name} - Type: {data_type}") filename = f"{run_timestamp}_{step_name}_{data_type}.txt" diff --git a/helpers.py b/helpers.py index 4caab5b0..1544700f 100644 --- a/helpers.py +++ b/helpers.py @@ -295,13 +295,18 @@ def get_email_address(firstname, lastname, website): def _get_gemini_api_key(): """Retrieves Gemini API Key from Config or Environment.""" logger = logging.getLogger(__name__) + print("DEBUG: _get_gemini_api_key called.") # Debug print api_key = Config.API_KEYS.get('openai') # Legacy slot + print(f"DEBUG: API Key from Config.API_KEYS['openai']: {api_key if api_key else 'None'}") # Debug print + if not api_key: # Fallback: Versuche Environment Variable, falls Config leer ist api_key = os.environ.get("OPENAI_API_KEY") + print(f"DEBUG: API Key from env OPENAI_API_KEY: {api_key if api_key else 'None'}") # Debug print if not api_key: # Fallback 2: Versuche den Gemini Key direkt api_key = os.environ.get("GEMINI_API_KEY") or Config.API_KEYS.get('gemini') + print(f"DEBUG: API Key from env GEMINI_API_KEY or Config.API_KEYS['gemini']: {api_key if api_key else 'None'}") # Debug print if not api_key: logger.error("Fehler: Kein API Key gefunden (weder als 'openai' noch 'gemini').")