7a0da7932b
Backwards Compatibility / Verify Encryption Constants (push) Waiting to run
Backwards Compatibility / PyPI Version Compatibility (push) Waiting to run
Backwards Compatibility / Database Migration Tests (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Blocked by required conditions
Docker Tests (Consolidated) / detect-changes (push) Waiting to run
Docker Tests (Consolidated) / Build Test Image (push) Waiting to run
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Blocked by required conditions
Docker Tests (Consolidated) / Accessibility Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Unit Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Example Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / Production Image Smoke Test (push) Blocked by required conditions
Docker Tests (Consolidated) / Infrastructure Tests (push) Blocked by required conditions
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Waiting to run
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
93 lines
2.7 KiB
Python
93 lines
2.7 KiB
Python
"""
|
|
Quick fix to ensure search engine settings are loaded for test user.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from loguru import logger
|
|
|
|
# Add parent directory to path for imports
|
|
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
|
|
|
|
from local_deep_research.database.encrypted_db import db_manager
|
|
from local_deep_research.settings.manager import (
|
|
SettingsManager,
|
|
)
|
|
|
|
|
|
def fix_search_engines_for_user(username: str, password: str):
|
|
"""Ensure search engine settings are loaded for a user."""
|
|
|
|
logger.info(f"Fixing search engine settings for user: {username}")
|
|
|
|
# Open user database
|
|
engine = db_manager.open_user_database(username, password)
|
|
if not engine:
|
|
logger.error("Failed to open user database")
|
|
return False
|
|
|
|
# Get database session
|
|
Session = db_manager.Session
|
|
if not Session:
|
|
logger.error("Failed to get database session factory")
|
|
return False
|
|
|
|
with Session() as db_session:
|
|
try:
|
|
# Create settings manager
|
|
settings_manager = SettingsManager(db_session)
|
|
|
|
# Check if we need to load defaults
|
|
from local_deep_research.database.models import Setting
|
|
|
|
search_engine_count = (
|
|
db_session.query(Setting)
|
|
.filter(Setting.key.like("search.engine.%.display_name"))
|
|
.count()
|
|
)
|
|
|
|
if search_engine_count == 0:
|
|
logger.info(
|
|
"No search engine settings found. Loading defaults..."
|
|
)
|
|
settings_manager.load_from_defaults_file(commit=True)
|
|
logger.info("Default settings loaded successfully")
|
|
else:
|
|
logger.info(
|
|
f"Found {search_engine_count} search engine settings"
|
|
)
|
|
|
|
# Verify settings were loaded
|
|
search_engines = (
|
|
db_session.query(Setting)
|
|
.filter(Setting.key.like("search.engine.%.display_name"))
|
|
.all()
|
|
)
|
|
|
|
logger.info(f"Search engines after fix: {len(search_engines)}")
|
|
for engine in search_engines[:5]: # Show first 5
|
|
logger.info(f" - {engine.key}: {engine.value}")
|
|
|
|
return True
|
|
|
|
except Exception:
|
|
logger.exception("Failed to fix search engines")
|
|
db_session.rollback()
|
|
return False
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import os
|
|
|
|
os.environ["LDR_BOOTSTRAP_ALLOW_UNENCRYPTED"] = "true"
|
|
|
|
# Fix for test user
|
|
fix_search_engines_for_user(
|
|
"testuser", "testpassword123"
|
|
) # pragma: allowlist secret
|
|
|
|
# Also fix for any other common test users
|
|
fix_search_engines_for_user("apitest_user", "apitest_pass123")
|