{"record":{"id":"176dff5a4865ac2e","repo":"Tencent/WeKnora","slug":"doris-connection-requires-database","errorCode":null,"errorMessage":"doris connection requires database","messagePattern":"doris connection requires database","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/container/engine_factory.go","lineNumber":336,"sourceCode":"\t}\n\trepo := weaviateRepo.NewWeaviateRetrieveEngineRepository(client, &store.IndexConfig)\n\treturn retriever.NewKVHybridRetrieveEngine(repo, types.WeaviateRetrieverEngineType), nil\n}\n\n// createDorisEngine 创建 Apache Doris 检索引擎服务。\n//\n// Doris 同时使用两个端口：\n//   - MySQL 协议（默认 9030）走 database/sql 做主链路读写；\n//   - HTTP（默认 FE 8030）走 Stream Load 做 partial update。\n//\n// Addr 字段承担 host:9030 的 MySQL 端点；HTTPPort + Addr 的 host 部分组成 HTTP base URL。\nfunc createDorisEngine(store types.VectorStore) (interfaces.RetrieveEngineService, error) {\n\tcc := store.ConnectionConfig\n\tif cc.Addr == \"\" {\n\t\treturn nil, fmt.Errorf(\"doris connection requires addr (host:port)\")\n\t}\n\tif cc.Database == \"\" {\n\t\treturn nil, fmt.Errorf(\"doris connection requires database\")\n\t}\n\n\tmc := mysql.NewConfig()\n\tmc.User = cc.Username\n\tmc.Passwd = cc.Password\n\tutils.RegisterMySQLSSRFDialer()\n\tmc.Net = utils.MySQLSSRFNetwork\n\tmc.Addr = cc.Addr\n\tmc.DBName = cc.Database\n\tmc.Params = map[string]string{\"charset\": \"utf8mb4\"}\n\tmc.ParseTime = true\n\tmc.Loc = time.Local\n\tdb, err := sql.Open(\"mysql\", mc.FormatDSN())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create doris client: %w\", err)\n\t}\n\tdb.SetMaxOpenConns(20)\n\tdb.SetMaxIdleConns(5)","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/container/engine_factory.go#L318-L354","documentation":"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.","triggerScenarios":"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.","commonSituations":"Default configs omitting the database field; env var for database name unset; user assumes the username's default database is used (it is not).","solutions":["Set ConnectionConfig.Database to the target Doris database name","Create the database in Doris first if it does not exist (CREATE DATABASE ...)","Verify the config-loading code maps the database key correctly into cc.Database"],"exampleFix":"// before\ncc := types.ConnectionConfig{Addr: \"fe.example.com:9030\"}\n// after\ncc := types.ConnectionConfig{Addr: \"fe.example.com:9030\", Database: \"analytics\"}","handlingStrategy":"validation","validationCode":"func requireDorisDatabase(cc types.ConnectionConfig) error {\n    if cc.Database == \"\" { return errors.New(\"doris database is required\") }\n    return nil\n}","typeGuard":"func dorisDatabaseSet(cc types.ConnectionConfig) bool { return strings.TrimSpace(cc.Database) != \"\" }","tryCatchPattern":"engine, err := createEngineServiceFromStore(ctx, store)\nif err != nil && strings.Contains(err.Error(), \"requires database\") {\n    return fmt.Errorf(\"set ConnectionConfig.Database for the Doris store: %w\", err)\n}","preventionTips":["Always set Database explicitly; Doris does not fall back to a default DB","Create the target database in Doris before pointing the store at it","Map the database env var/config key in the loader and test it","Trim values so whitespace-only strings do not slip through"],"tags":["doris","config-validation","missing-config"],"backgroundTag":"missing-required-config-field","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}