vxcontrol/pentagi · error

failed to get vector store log: %w

Error message

failed to get vector store log: %w

What it means

GetLog wraps errors from the GetFlowVectorStoreLog SQLC query, which selects a vector-store log row by both ID and FlowID. Most commonly this wraps sql.ErrNoRows when the message ID does not exist or belongs to a different flow; it can also wrap connectivity or context errors.

Source

Thrown at backend/pkg/controller/vslog.go:89

		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

  1. Check errors.Is(err, sql.ErrNoRows) first and treat it as a not-found case, not a server failure.
  2. Confirm the msgID belongs to the flow whose worker you are using.
  3. Verify DB connectivity if the wrapped error is a connection error.
  4. Surface a typed not-found error to the GraphQL layer instead of leaking the raw DB error.

Example fix

// before
msg, err := worker.GetLog(ctx, msgID)
if err != nil { return err }
// after
msg, err := worker.GetLog(ctx, msgID)
if err != nil {
    if errors.Is(err, sql.ErrNoRows) {
        return graphql.ErrorNotFound("vector store log %d not found in flow", msgID)
    }
    return fmt.Errorf("get log: %w", err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

if msgID <= 0 {
    return fmt.Errorf("invalid vector store log id %d", msgID)
}
// ensure the ID came from the same flow you're querying
if !msgBelongsToFlow(msgID, flowID) {
    return database.Vecstorelog{}, sql.ErrNoRows
}

Type guard

func isLogNotFound(err error) bool {
    return errors.Is(err, sql.ErrNoRows) ||
        strings.Contains(err.Error(), "failed to get vector store log") && errors.Is(err, sql.ErrNoRows)
}

Try / catch

msg, err := worker.GetLog(ctx, msgID)
switch {
case err == nil:
    use(msg)
case errors.Is(err, sql.ErrNoRows):
    renderNotFound(msgID) // expected: stale ID or wrong flow
default:
    return fmt.Errorf("get vector store log: %w", err) // real DB failure
}

Prevention

When it happens

Trigger: Calling GetLog(ctx, msgID) with an ID that was never created, was deleted, or belongs to another flow (the query scopes by vslw.flowID); the DB is unreachable; ctx expired.

Common situations: Frontend requesting a log entry from a stale subscription after the flow was cleaned up; cross-flow ID reuse assumptions; pagination clients holding onto old IDs after data retention cleanup.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01). Data as JSON: /api/errors/108b21060877c15d. Report an issue: GitHub.