ARCHITECTURE FIX:
- aws-admin IntegrationSettings will NEVER exist (it's a legacy pattern)
- Only user's own account IntegrationSettings can exist (if they override defaults)
- Otherwise GlobalIntegrationSettings is used directly
- API keys are ALWAYS from GlobalIntegrationSettings (accounts cannot override API keys)
REMOVED:
- All aws-admin Account lookups
- All aws-admin IntegrationSettings fallback attempts
- Confusing nested try/except chains
CORRECT FLOW NOW:
1. Try account's IntegrationSettings for config overrides
2. Use GlobalIntegrationSettings for missing values and ALL API keys
3. No intermediate aws-admin lookups
ROOT CAUSES IDENTIFIED:
1. GlobalAIPrompt template had unescaped JSON braces that broke Python's .format()
- Python treats {...} as placeholders, causing KeyError when rendering
- Escaped JSON braces to {{...}} while preserving {title}, {content}, {max_images}
2. Image functions hardcoded aws-admin IntegrationSettings which didn't exist
- Functions failed when aws-admin account had no IntegrationSettings
- Added GlobalIntegrationSettings fallback for all missing values
CHANGES:
- Fixed GlobalAIPrompt.image_prompt_extraction template in database (escaped JSON)
- Updated generate_image_prompts._get_max_in_article_images() with fallback
- Updated generate_images.prepare_data() with fallback for all image settings
- Updated tasks.process_image_generation_queue() with fallback for config + API keys
TESTED: Template rendering now works, GlobalIntegrationSettings.max_in_article_images=4
- Improved response parsing in AICore to handle both array and dictionary formats, including detailed error logging.
- Updated image directory handling in tasks to prioritize web-accessible paths for image storage, with robust fallback mechanisms.
- Adjusted image URL generation in serializers and frontend components to support new directory structure and ensure proper accessibility.
- Updated image directory handling to prioritize mounted volume for persistence.
- Enhanced logging for directory write tests and fallback mechanisms.
- Introduced a new endpoint to serve image files directly from local paths.
- Added error handling for file serving, including checks for file existence and readability.
- Updated the frontend to include a new ContentView component and corresponding route.
- Added primary_keyword, secondary_keywords, tags, and categories fields to Tasks model
- Updated generate_content function to handle full JSON response with all SEO fields
- Improved progress bar animation: smooth 1% increments every 300ms
- Enhanced step detection for content generation vs clustering vs ideas
- Fixed progress modal to show correct messages for each function type
- Added comprehensive logging to Keywords and Tasks pages for AI functions
- Fixed error handling to show meaningful error messages instead of generic failures