Tencent/WeKnora · error

doris connection requires database

Error message

doris connection requires database

What it means

A guard error from createDorisEngine: the Doris store must specify which database (cc.Database) to connect to. The database name is placed into the MySQL DSN's DBName, so an empty value is rejected before opening the connection.

Source

Thrown at internal/container/engine_factory.go:336

	}
	repo := weaviateRepo.NewWeaviateRetrieveEngineRepository(client, &store.IndexConfig)
	return retriever.NewKVHybridRetrieveEngine(repo, types.WeaviateRetrieverEngineType), nil
}

// createDorisEngine 创建 Apache Doris 检索引擎服务。
//
// Doris 同时使用两个端口:
//   - MySQL 协议(默认 9030)走 database/sql 做主链路读写;
//   - HTTP(默认 FE 8030)走 Stream Load 做 partial update。
//
// Addr 字段承担 host:9030 的 MySQL 端点;HTTPPort + Addr 的 host 部分组成 HTTP base URL。
func createDorisEngine(store types.VectorStore) (interfaces.RetrieveEngineService, error) {
	cc := store.ConnectionConfig
	if cc.Addr == "" {
		return nil, fmt.Errorf("doris connection requires addr (host:port)")
	}
	if cc.Database == "" {
		return nil, fmt.Errorf("doris connection requires database")
	}

	mc := mysql.NewConfig()
	mc.User = cc.Username
	mc.Passwd = cc.Password
	utils.RegisterMySQLSSRFDialer()
	mc.Net = utils.MySQLSSRFNetwork
	mc.Addr = cc.Addr
	mc.DBName = cc.Database
	mc.Params = map[string]string{"charset": "utf8mb4"}
	mc.ParseTime = true
	mc.Loc = time.Local
	db, err := sql.Open("mysql", mc.FormatDSN())
	if err != nil {
		return nil, fmt.Errorf("create doris client: %w", err)
	}
	db.SetMaxOpenConns(20)
	db.SetMaxIdleConns(5)

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Set ConnectionConfig.Database to the target Doris database name
  2. Create the database in Doris first if it does not exist (CREATE DATABASE ...)
  3. Verify the config-loading code maps the database key correctly into cc.Database

Example fix

// before
cc := types.ConnectionConfig{Addr: "fe.example.com:9030"}
// after
cc := types.ConnectionConfig{Addr: "fe.example.com:9030", Database: "analytics"}
Defensive patterns

Strategy: validation

Validate before calling

func requireDorisDatabase(cc types.ConnectionConfig) error {
    if cc.Database == "" { return errors.New("doris database is required") }
    return nil
}

Type guard

func dorisDatabaseSet(cc types.ConnectionConfig) bool { return strings.TrimSpace(cc.Database) != "" }

Try / catch

engine, err := createEngineServiceFromStore(ctx, store)
if err != nil && strings.Contains(err.Error(), "requires database") {
    return fmt.Errorf("set ConnectionConfig.Database for the Doris store: %w", err)
}

Prevention

When it happens

Trigger: Creating a Doris engine where cc.Addr is set but cc.Database is empty — commonly when credentials/address are configured but the target database was never specified in the store config.

Common situations: Default configs omitting the database field; env var for database name unset; user assumes the username's default database is used (it is not).

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/176dff5a4865ac2e. Report an issue: GitHub.