{"record":{"id":"ef083862ea99058c","repo":"iflytek/astron-agent","slug":"database-password-is-required","errorCode":null,"errorMessage":"database password is required","messagePattern":"database password is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/tenant/config/config.go","lineNumber":45,"sourceCode":"\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{}\n\t// load config from local file\n\tlocalLoader := NewLocalLoader(path)\n\tif err := localLoader.Load(cfg); err != nil {\n\t\tfmt.Printf(\"failed to load config from file: %v\\n\", err)\n\t}\n\t// load config from environment variables","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/tenant/config/config.go#L27-L63","documentation":"Config.Validate requires DataBase.Password to be non-empty; this error means the database password was never supplied, so the service refuses to start rather than attempt an unauthenticated DB connection. Sources are the TOML `[database] password` key and the DATABASE_PASSWORD env var.","triggerScenarios":"LoadConfig(path) -> Config.Validate() returns this when `[database] password` is absent in the TOML and DATABASE_PASSWORD is unset/empty.","commonSituations":"K8s Secret not injected into the pod (envFrom missing), secret key mismatch (DB_PASSWORD vs DATABASE_PASSWORD), intentionally blank password in dev config, or credential rotation removing the var from the manifest.","solutions":["Set DATABASE_PASSWORD in the environment, ideally via a Secret (DATABASE_PASSWORD=<secret>).","Add `password = \"...\"` under the [database] section of the TOML config file (avoid committing real secrets).","Verify the Secret/ConfigMap mounting and that the key name inside it is exactly DATABASE_PASSWORD.","If using *_FILE style injection, note this loader only reads direct env vars — export the value into DATABASE_PASSWORD in the entrypoint."],"exampleFix":"// before: deployment env\n//   DATABASE_USERNAME: tenant\n// after: add password from secret\n//   DATABASE_USERNAME: tenant\n//   DATABASE_PASSWORD:\n//     valueFrom:\n//       secretKeyRef: {name: tenant-db, key: password}","handlingStrategy":"validation","validationCode":"if os.Getenv(\"DATABASE_PASSWORD\") == \"\" {\n\treturn errors.New(\"DATABASE_PASSWORD must be set (via Secret) before tenant startup\")\n}","typeGuard":null,"tryCatchPattern":"cfg, err := config.LoadConfig(path)\nif err != nil {\n\tif strings.Contains(err.Error(), \"database password is required\") {\n\t\tlog.Fatalf(\"DATABASE_PASSWORD missing — check secretKeyRef: %v\", err)\n\t}\n\treturn err\n}","preventionTips":["Mount DB password via secretKeyRef and confirm the key is exactly DATABASE_PASSWORD","Never rely on empty passwords in dev; use a local Secret file consistently","Add a startup preflight that fails fast with a clear message when the var is absent","Audit Helm values for the password key during releases"],"tags":["configuration","database","credentials","go"],"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"}