{"record":{"id":"9bd95d977fcc8ad7","repo":"iflytek/astron-agent","slug":"mysql-password-is-empty","errorCode":null,"errorMessage":"mysql password is empty","messagePattern":"mysql password is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/tenant/tools/database/database.go","lineNumber":77,"sourceCode":"\tif err := client.Ping(); err != nil {\n\t\treturn err\n\t}\n\n\tif err := initializeMysqlClient(client, conf.TenantBootstrap); err != nil {\n\t\t_ = client.Close()\n\t\treturn err\n\t}\n\n\tdb.mysql = client\n\treturn nil\n}\n\nfunc parseMysqlConfig(conf *config.Config) (string, *mysql.Config, error) {\n\tif len(conf.DataBase.UserName) == 0 {\n\t\treturn \"\", nil, errors.New(\"mysql username is empty\")\n\t}\n\tif len(conf.DataBase.Password) == 0 {\n\t\treturn \"\", nil, errors.New(\"mysql password is empty\")\n\t}\n\tif len(conf.DataBase.Url) == 0 {\n\t\treturn \"\", nil, errors.New(\"mysql url is empty\")\n\t}\n\tif err := conf.TenantBootstrap.Validate(); err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"invalid tenant bootstrap credentials: %w\", err)\n\t}\n\n\tdsn := fmt.Sprintf(\"%s:%s@tcp%s\", conf.DataBase.UserName, conf.DataBase.Password, conf.DataBase.Url)\n\tparsedDsn, err := mysql.ParseDSN(dsn)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\treturn dsn, parsedDsn, nil\n}\n\nfunc initializeMysqlClient(\n\tclient *sql.DB,","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/tenant/tools/database/database.go#L59-L95","documentation":"parseMysqlConfig rejects the tenant service configuration when DataBase.Password is empty. Startup fails fast before any DB connection is attempted; fix the deployment's database credential configuration.","triggerScenarios":"buildMysql → parseMysqlConfig with database.password empty/missing in config or its secret source.","commonSituations":"K8s secret not containing the password key, env var interpolation failure (empty ${MYSQL_PASSWORD}), rotated secret not restarted, or a local dev config with the password stripped for the repo.","solutions":["Set database.password via the mounted secret/env and restart the tenant service","Verify the secret key name matches what the config template expects","Check env var expansion in Compose/Helm isn't producing an empty value","Confirm the MySQL user actually has a password matching the configured value"],"exampleFix":"// before\ndatabase:\n  password: \"\"\n// after\ndatabase:\n  password: \"${MYSQL_PASSWORD}\" # injected from secret","handlingStrategy":"validation","validationCode":"if conf.DataBase.Password == \"\" { return errors.New(\"mysql password must be configured\") }","typeGuard":null,"tryCatchPattern":"db, err := NewDatabase(conf); if err != nil && strings.Contains(err.Error(), \"password is empty\") { log.Fatal(\"MYSQL password missing — check secret mount\") }","preventionTips":["Mount DB password secrets explicitly and verify at startup","Watch for empty env interpolation in Compose/Helm","Restart services after secret rotation"],"tags":["go","mysql","config","secrets"],"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-16T04:17:20.429Z"}