vxcontrol/pentagi · error
failed to create vector store log: %w
Error message
failed to create vector store log: %w
What it means
PutLog wraps any error returned by the CreateVectorStoreLog SQLC query with "failed to create vector store log: %w". It means inserting a vector-store log row (query, action, result, flow/task/subtask IDs) into PostgreSQL failed. The underlying cause (connection failure, constraint violation, context cancellation) is preserved via %w for errors.Is/As inspection.
Source
Thrown at backend/pkg/controller/vslog.go:75
taskID *int64,
subtaskID *int64,
) (int64, error) {
vslw.mx.Lock()
defer vslw.mx.Unlock()
vsLog, err := vslw.db.CreateVectorStoreLog(ctx, database.CreateVectorStoreLogParams{
Initiator: initiator,
Executor: executor,
Filter: filter,
Query: query,
Action: action,
Result: result,
FlowID: vslw.flowID,
TaskID: database.Int64ToNullInt64(taskID),
SubtaskID: database.Int64ToNullInt64(subtaskID),
})
if err != nil {
return 0, fmt.Errorf("failed to create vector store log: %w", err)
}
vslw.pub.VectorStoreLogAdded(ctx, vsLog)
return vsLog.ID, nil
}
func (vslw *flowVectorStoreLogWorker) GetLog(ctx context.Context, msgID int64) (database.Vecstorelog, error) {
msg, err := vslw.db.GetFlowVectorStoreLog(ctx, database.GetFlowVectorStoreLogParams{
ID: msgID,
FlowID: vslw.flowID,
})
if err != nil {
return database.Vecstorelog{}, fmt.Errorf("failed to get vector store log: %w", err)
}
return msg, nil
}View on GitHub (pinned to ea665308ba)
Solutions
- Unwrap and log the wrapped error to identify the root cause (check pgconn.PgError code for FK/constraint issues).
- Verify PostgreSQL connectivity and the connection pool (docker compose ps, DSN in .env).
- If FK violations occur, ensure the flow/task/subtask rows exist before logging, or make TaskID/SubtaskID null.
- Add retry with backoff for transient connection errors before failing the agent step.
Example fix
// before
id, err := worker.PutLog(ctx, init, exec, filter, q, action, result, &taskID, &subtaskID)
if err != nil { return err }
// after
id, err := worker.PutLog(ctx, init, exec, filter, q, action, result, &taskID, &subtaskID)
if err != nil {
var pgErr *pgconn.PgError
if errors.As(err, &pgErr) && pgErr.Code == "23503" {
// foreign key violation: log without task/subtask linkage
id, err = worker.PutLog(ctx, init, exec, filter, q, action, result, nil, nil)
}
if err != nil { return fmt.Errorf("put log: %w", err) }
} Defensive patterns
Strategy: retry
Validate before calling
if vslw.flowID == 0 {
return fmt.Errorf("cannot put vector store log: flow not set")
}
if err := ctx.Err(); err != nil {
return err // context already cancelled, insert would fail
}
if err := db.Ping(ctx); err != nil {
return fmt.Errorf("database unavailable: %w", err)
} Type guard
func isFKViolation(err error) bool {
var pgErr *pgconn.PgError
return errors.As(err, &pgErr) && pgErr.Code == "23503"
} Try / catch
id, err := worker.PutLog(ctx, init, exec, filter, q, action, result, taskID, subtaskID)
if err != nil {
var pgErr *pgconn.PgError
if errors.As(err, &pgErr) && isTransient(pgErr.Code) {
id, err = retryWithBackoff(3, func() (int64, error) {
return worker.PutLog(ctx, init, exec, filter, q, action, result, taskID, subtaskID)
})
}
if err != nil { log.Warn("vector store log dropped", "err", err) }
} Prevention
- Keep flow/task/subtask rows alive for the lifetime of logging, or pass nil IDs.
- Monitor DB connection pool saturation during heavy agent activity.
- Use valid VecstoreActionType values only (check-constraint friendly).
- Alert on wrapped root causes via errors.As(*pgconn.PgError).
When it happens
Trigger: Calling PutLog when the DB connection is down; the flow row referenced by FlowID no longer exists (FK violation); an invalid VecstoreActionType violates a check constraint; ctx is cancelled or times out mid-insert.
Common situations: Database restart or pool exhaustion during heavy agent activity; running flows pointing at rows deleted by manual cleanup; network partition between the app and PostgreSQL; misconfigured DSN in the environment.
Related errors
- failed to create flow in DB: %w
- failed to delete assistant %d: %w
- failed to rename flow %d: %w
- failed to update flow provider in DB: %w
- failed to get vector store log: %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/386e8b0c48425a78.
Report an issue: GitHub.