{"record":{"id":"0dd8a4d7b11068a3","repo":"iflytek/astron-agent","slug":"database-type-is-required","errorCode":null,"errorMessage":"database type is required","messagePattern":"database type is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/tenant/config/config.go","lineNumber":39,"sourceCode":"\t\tLogFile string `toml:\"path\"`\n\t} `toml:\"log\"`\n\n\t// TenantBootstrap is loaded only from deployment-managed environment\n\t// variables or credential files. It is intentionally omitted from String so\n\t// credentials cannot be exposed by routine configuration logging.\n\tTenantBootstrap TenantBootstrapCredentials\n}\n\nfunc (c *Config) String() string {\n\treturn fmt.Sprintf(\"Config{Server: %v, DataBase: %v, Log: %v}\", c.Server, c.DataBase, c.Log)\n}\n\nfunc (c *Config) Validate() error {\n\tif c.Server.Port == 0 {\n\t\treturn fmt.Errorf(\"server port is required\")\n\t}\n\tif c.DataBase.DBType == \"\" {\n\t\treturn fmt.Errorf(\"database type is required\")\n\t}\n\tif c.DataBase.UserName == \"\" {\n\t\treturn fmt.Errorf(\"database username is required\")\n\t}\n\tif c.DataBase.Password == \"\" {\n\t\treturn fmt.Errorf(\"database password is required\")\n\t}\n\tif c.DataBase.Url == \"\" {\n\t\treturn fmt.Errorf(\"database url is required\")\n\t}\n\tif c.Log.LogFile == \"\" {\n\t\treturn fmt.Errorf(\"log file is required\")\n\t}\n\treturn nil\n}\n\nfunc LoadConfig(path string) (*Config, error) {\n\tcfg := &Config{}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/tenant/config/config.go#L21-L57","documentation":"Config.Validate requires DataBase.DBType to be non-empty; this error indicates the database driver/type (e.g. postgres, mysql) was never configured. LoadConfig merges the TOML file and DATABASE_* environment variables before validating, so the value was absent from both sources.","triggerScenarios":"LoadConfig(path) -> Config.Validate() returns this when the TOML `[database] dbType` key is missing/empty and the DATABASE_DB_TYPE environment variable is unset or empty.","commonSituations":"Fresh deployments with a partial .toml, renaming the env var (e.g. DB_TYPE instead of DATABASE_DB_TYPE), secrets/config ConfigMaps not mounted, or Helm values omitting the database type key.","solutions":["Set DATABASE_DB_TYPE in the environment (e.g. DATABASE_DB_TYPE=postgres).","Add `dbType = \"postgres\"` under the [database] section of the TOML config file.","Verify the env var name is exactly DATABASE_DB_TYPE (check for typos like DATABASE_DBTYPE).","Confirm the config file path passed to LoadConfig is valid, since a failed file load is only logged, not returned."],"exampleFix":"// before\n[database]\nusername = \"tenant\"\n// after\n[database]\ndbType = \"postgres\"\nusername = \"tenant\"","handlingStrategy":"validation","validationCode":"if os.Getenv(\"DATABASE_DB_TYPE\") == \"\" {\n\treturn errors.New(\"DATABASE_DB_TYPE must be set (e.g. postgres) before startup\")\n}","typeGuard":null,"tryCatchPattern":"cfg, err := config.LoadConfig(path)\nif err != nil {\n\tif strings.Contains(err.Error(), \"database type is required\") {\n\t\tlog.Fatalf(\"DATABASE_DB_TYPE not set: %v\", err)\n\t}\n\treturn err\n}","preventionTips":["Set DATABASE_DB_TYPE explicitly in every environment's manifest","Use env var names exactly as the loader defines them (DATABASE_DB_TYPE, not DB_TYPE)","Keep a template .toml with [database] dbType filled in","Smoke-test startup configs in CI before deploying"],"tags":["configuration","database","go","tenant-service"],"backgroundTag":"missing-required-config-field","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}