fix: resolve owner_id from CallerIdentity on corpus create — prevents NOT NULL constraint violation in single-user mode
Some checks failed
Stuffle/nebula-os/pipeline/head There was a failure building this commit
Some checks failed
Stuffle/nebula-os/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -22,11 +22,12 @@ import secrets
|
||||
import time
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from fastapi import APIRouter, BackgroundTasks, HTTPException, Request
|
||||
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, Request
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from libs.db.connection import get_db
|
||||
from libs.logging import get_logger
|
||||
from src.api.dependencies import CallerIdentity, get_caller_identity
|
||||
from src.common.types import ExecutionContext
|
||||
|
||||
log = get_logger("api.corpora")
|
||||
@@ -221,11 +222,13 @@ async def classify_url_endpoint(
|
||||
async def create_corpus(
|
||||
body: CreateCorpusRequest,
|
||||
request: Request,
|
||||
caller: CallerIdentity = Depends(get_caller_identity),
|
||||
) -> Dict[str, Any]:
|
||||
"""Create a new empty corpus."""
|
||||
db = get_db()
|
||||
cid = _cid()
|
||||
corpus_id = _corpus_id()
|
||||
owner_id = body.owner_id or caller.created_by
|
||||
|
||||
log.info("corpus_create", {
|
||||
"component": "api.corpora",
|
||||
@@ -235,6 +238,7 @@ async def create_corpus(
|
||||
"metadata": {
|
||||
"name": body.name,
|
||||
"embedding_model": body.embedding_model,
|
||||
"owner_id": owner_id,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -249,7 +253,7 @@ async def create_corpus(
|
||||
corpus_id,
|
||||
body.name,
|
||||
body.description,
|
||||
body.owner_id,
|
||||
owner_id,
|
||||
body.embedding_model,
|
||||
body.embedding_dims,
|
||||
body.chunk_size,
|
||||
|
||||
Reference in New Issue
Block a user