
import sys
import os
from dotenv import load_dotenv

# Explicitly load .env from the project root
dotenv_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '.env'))
print(f"Loading .env from: {dotenv_path}")
load_dotenv(dotenv_path=dotenv_path, override=True)

sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from config import settings

print("\n--- DEBUGGING CONFIG TYPES ---")
try:
    print(f"UDF_VERTICAL: {settings.UDF_VERTICAL} (Type: {type(settings.UDF_VERTICAL)})")
    print(f"UDF_SUMMARY: {settings.UDF_SUMMARY} (Type: {type(settings.UDF_SUMMARY)})")
    print(f"UDF_OPENER: {settings.UDF_OPENER} (Type: {type(settings.UDF_OPENER)})")
    print(f"UDF_OPENER_SECONDARY: {settings.UDF_OPENER_SECONDARY} (Type: {type(settings.UDF_OPENER_SECONDARY)})")
    print(f"UDF_LAST_UPDATE: {settings.UDF_LAST_UPDATE} (Type: {type(settings.UDF_LAST_UPDATE)})")
    print(f"UDF_LAST_OUTREACH: {settings.UDF_LAST_OUTREACH} (Type: {type(settings.UDF_LAST_OUTREACH)})")
    
    # Test dictionary creation to force the error if a key is a dict
    print("\nAttempting to create dictionary with these keys...")
    test_dict = {
        settings.UDF_VERTICAL: "Vertical",
        settings.UDF_SUMMARY: "Summary",
        settings.UDF_OPENER: "Opener",
        settings.UDF_OPENER_SECONDARY: "Opener 2",
        settings.UDF_LAST_UPDATE: "Last Update",
        settings.UDF_LAST_OUTREACH: "Last Outreach"
    }
    print("✅ Dictionary creation SUCCESSFUL.")

except TypeError as e:
    print(f"\n❌ TypeError CAUGHT: {e}")
    print("One of the settings above is likely a dictionary or unhashable type!")

except Exception as e:
    print(f"\n❌ Unknown Error: {e}")
