|
|
|
@ -133,11 +133,13 @@ try: |
|
|
|
if "username" not in bg: |
|
|
|
if "username" not in bg: |
|
|
|
logging.error(f"Invalid entry in {AUTHOR_BACKGROUNDS_FILE}: Missing 'username' key in {bg}") |
|
|
|
logging.error(f"Invalid entry in {AUTHOR_BACKGROUNDS_FILE}: Missing 'username' key in {bg}") |
|
|
|
raise ValueError("Each author background must have a 'username' key") |
|
|
|
raise ValueError("Each author background must have a 'username' key") |
|
|
|
|
|
|
|
if "engagement_themes" not in bg or not isinstance(bg["engagement_themes"], list) or not bg["engagement_themes"]: |
|
|
|
|
|
|
|
logging.error(f"Invalid entry in {AUTHOR_BACKGROUNDS_FILE}: Missing or invalid 'engagement_themes' for {bg.get('username', 'unknown')}: {bg}") |
|
|
|
|
|
|
|
raise ValueError("Each author background must have a non-empty 'engagement_themes' list") |
|
|
|
username = bg["username"] |
|
|
|
username = bg["username"] |
|
|
|
if not isinstance(username, str): |
|
|
|
if not isinstance(username, str): |
|
|
|
logging.error(f"Invalid username type in {AUTHOR_BACKGROUNDS_FILE}: {username} (type: {type(username)})") |
|
|
|
logging.error(f"Invalid username type in {AUTHOR_BACKGROUNDS_FILE}: {username} (type: {type(username)})") |
|
|
|
raise ValueError("Username must be a string") |
|
|
|
raise ValueError("Username must be a string") |
|
|
|
# Normalize the username to handle encoding differences |
|
|
|
|
|
|
|
cleaned_username = unicodedata.normalize('NFC', username.strip().lower()) |
|
|
|
cleaned_username = unicodedata.normalize('NFC', username.strip().lower()) |
|
|
|
AUTHOR_BACKGROUNDS[cleaned_username] = bg |
|
|
|
AUTHOR_BACKGROUNDS[cleaned_username] = bg |
|
|
|
logging.debug(f"Added to AUTHOR_BACKGROUNDS: key='{cleaned_username}', value={bg}") |
|
|
|
logging.debug(f"Added to AUTHOR_BACKGROUNDS: key='{cleaned_username}', value={bg}") |
|
|
|
|