fix: 4 API bugs found by integration tests
Check Cross-Plugin Imports / check (push) Has been cancelled
Check Cross-Plugin Imports / check (push) Has been cancelled
1. tags.owner_id column missing — Migration 0105 adds owner_id to tags table 2. contacts trigger first_name vs firstname — Migration 0105 recreates unified_search TSV trigger with correct column names (firstname, surname, etc.) 3. create_webhook() missing is_system_admin param — Add to webhook_service.py 4. Missing GET /api/v1/search endpoint — Add to unified_search/routes.py with shared _do_search() helper for GET+POST Alembic head: 0104 → 0105
This commit is contained in:
@@ -42,13 +42,27 @@ router = APIRouter(prefix="/api/v1/search", tags=["search"])
|
||||
|
||||
# ─── Search ───
|
||||
|
||||
@router.post("", dependencies=[Depends(require_permission("search:read"))])
|
||||
async def search(
|
||||
req: SearchRequest,
|
||||
@router.get("", dependencies=[Depends(require_permission("search:read"))])
|
||||
async def search_get(
|
||||
q: str = Query(..., min_length=1, max_length=500, description="Search query"),
|
||||
entity_types: str | None = Query(None, description="Comma-separated entity types to search"),
|
||||
limit: int = Query(default=20, ge=1, le=100),
|
||||
offset: int = Query(default=0, ge=0),
|
||||
current_user: dict = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> SearchResponse:
|
||||
"""Perform hybrid search with KI query understanding."""
|
||||
"""Perform hybrid search via GET (same as POST but with query params)."""
|
||||
types_list = entity_types.split(",") if entity_types else None
|
||||
req = SearchRequest(query=q, entity_types=types_list, limit=limit, offset=offset)
|
||||
return await _do_search(req, current_user, db)
|
||||
|
||||
|
||||
async def _do_search(
|
||||
req: SearchRequest,
|
||||
current_user: dict,
|
||||
db: AsyncSession,
|
||||
) -> SearchResponse:
|
||||
"""Shared search logic used by both GET and POST endpoints."""
|
||||
tenant_id = uuid.UUID(current_user["tenant_id"])
|
||||
user_id = uuid.UUID(current_user["user_id"])
|
||||
is_system_admin = current_user.get("is_system_admin", False)
|
||||
@@ -107,6 +121,16 @@ async def search(
|
||||
)
|
||||
|
||||
|
||||
@router.post("", dependencies=[Depends(require_permission("search:read"))])
|
||||
async def search(
|
||||
req: SearchRequest,
|
||||
current_user: dict = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> SearchResponse:
|
||||
"""Perform hybrid search with KI query understanding."""
|
||||
return await _do_search(req, current_user, db)
|
||||
|
||||
|
||||
# ─── Suggest / Autocomplete ───
|
||||
|
||||
@router.get("/suggest", dependencies=[Depends(require_permission("search:read"))])
|
||||
|
||||
Reference in New Issue
Block a user