fix(audit): P0-P3 audit fixes — 838 ruff errors → 0, 30 F821 bugs fixed, 118 files changed
- P0: hooks.py 3-tuple fix, trigger_dispatcher Contract, contacts/plugin unregister_actions_by_owner - P0: 5 test files — check_permission mocks removed, hardcoded DB credential → env var - P1: attachment_service DmsFile via Contract helper, restore_registry/history_hooks dedup - P1: mail/plugin restore unregister, mcp_client datetime.now(UTC), saved_views/filters patterns - P1: ProtectedRoute fail-closed, 13 test assertion fixes (bcrypt, DB-URLs, SECRET_KEYs) - P2: deprecated notifications → post_system_message (3 files), forgejo Base, report_generator lazy import - P2: webhooks permissions, deps.py/roles.py plugin perms removed, import_export default - P2: address/tags/entity_links patterns removed, worker.py Contract-Umgehungen fixed - P2: 28 frontend TODOs (hardcoded constants, deprecated notification API) - P3: dead code, duplicates, deprecated imports, private attr, __import__ inline - P3: 8 frontend TODOs (LucideIcons, inline styles, XSS, i18n) - ruff: 838 → 0 (612 auto-fix + 246 manual + 27 F821 regression fix) - F821: 30 → 0 (AutomationDefinition, DmsFile, user_id, Path, Any, String) - Contract-Umgehungen: 2 neue gefunden (worker.py:169, worker.py:280) und gefixt
This commit is contained in:
@@ -19,10 +19,14 @@ from app.ai.llm_client import (
|
||||
EMBEDDING_DIMENSIONS,
|
||||
MAX_INPUT_CHARS,
|
||||
OPENROUTER_EMBEDDING_MODEL,
|
||||
build_model as _central_build_model,
|
||||
get_api_credentials as _central_get_api_credentials,
|
||||
llm_embed,
|
||||
)
|
||||
from app.ai.llm_client import (
|
||||
build_model as _central_build_model,
|
||||
)
|
||||
from app.ai.llm_client import (
|
||||
get_api_credentials as _central_get_api_credentials,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -46,7 +50,7 @@ OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1"
|
||||
|
||||
|
||||
async def _get_api_credentials(
|
||||
db: "AsyncSession | None", tenant_id: "uuid.UUID | None"
|
||||
db: AsyncSession | None, tenant_id: uuid.UUID | None
|
||||
) -> tuple[str | None, str | None, str | None]:
|
||||
"""Get API key, base_url and provider_type for embeddings.
|
||||
|
||||
@@ -68,8 +72,8 @@ def _build_model(model: str, provider_type: str | None) -> str:
|
||||
async def generate_embedding(
|
||||
text: str,
|
||||
model: str | None = None,
|
||||
db: "AsyncSession | None" = None,
|
||||
tenant_id: "uuid.UUID | None" = None,
|
||||
db: AsyncSession | None = None,
|
||||
tenant_id: uuid.UUID | None = None,
|
||||
) -> list[float]:
|
||||
"""Generate a single embedding via LiteLLM.
|
||||
|
||||
@@ -98,8 +102,8 @@ async def generate_embedding(
|
||||
async def generate_embeddings_batch(
|
||||
texts: list[str],
|
||||
model: str | None = None,
|
||||
db: "AsyncSession | None" = None,
|
||||
tenant_id: "uuid.UUID | None" = None,
|
||||
db: AsyncSession | None = None,
|
||||
tenant_id: uuid.UUID | None = None,
|
||||
) -> list[list[float]]:
|
||||
"""Generate embeddings for multiple texts in a single API call.
|
||||
|
||||
@@ -124,7 +128,7 @@ async def index_entity(
|
||||
entity_type: str,
|
||||
entity_id: uuid.UUID,
|
||||
tenant_id: uuid.UUID,
|
||||
db: "AsyncSession",
|
||||
db: AsyncSession,
|
||||
) -> bool:
|
||||
"""Generate and store embedding for a single entity.
|
||||
|
||||
@@ -134,6 +138,7 @@ async def index_entity(
|
||||
Returns True on success, False on failure.
|
||||
"""
|
||||
from sqlalchemy import text as sql_text
|
||||
|
||||
from app.plugins.builtins.unified_search.models import SearchIndexLog
|
||||
|
||||
async def _log_index(action: str, status: str, error: str | None = None) -> None:
|
||||
|
||||
Reference in New Issue
Block a user