iflytek/astron-agent · error
mysql database name is empty
Error message
mysql database name is empty
What it means
ensureMySQLDatabase requires parsedDsn.DBName to be non-empty because it must connect to and create the target tenant database using an admin DSN (with DBName blanked). An empty DBName means the DSN string built from config did not include the database path component, so there is no database to ensure.
Solutions
- Set the database name in the tenant config (or its env var) so the DSN ends with '/<dbname>'.
- Verify the DSN format: 'user:pass@tcp(host:port)/dbname' — confirm the '/dbname' part survives to ParseDSN.
- Re-run after checking parsedDsn.DBName via debug logging if unsure which segment was lost.
- Add a startup validation that database.name is non-empty alongside url/username/password.
Example fix
// before
dsn := fmt.Sprintf("%s:%s@tcp%s", user, pass, url)
// after
dsn := fmt.Sprintf("%s:%s@tcp%s/%s", user, pass, url, conf.DataBase.DataBase) Defensive patterns
Strategy: validation
Validate before calling
if conf.DataBase.DataBase == "" {
return errors.New("database.name must be set so the DSN contains /<dbname>")
} Prevention
- Always build DSNs as user:pass@tcp(host:port)/dbname and unit-test the format.
- Require database.name alongside url/user/password in config validation.
- Log a sanitized DSN (credentials redacted) at startup to verify the schema segment.
When it happens
Trigger: The DSN passed to mysql.ParseDSN lacked the '/dbname' suffix — e.g. database.name in config is empty while url/user/password are set, or the fmt.Sprintf in parseMysqlConfig was edited to drop the database segment.
Common situations: Config file missing database.name; env var for the schema name unset; DSN constructed manually as 'user:pass@tcp(host:port)' without the trailing '/tenantdb'.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- mysql username is empty
- mysql password is empty
- mysql url is empty
- mysql dsn is nil
- locked tenant bootstrap app does not match the reserved…
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/478420b4e8aa903b.
Report an issue: GitHub.
Appendix: source
Thrown at core/tenant/tools/database/database.go:117
return err
}
if err := reconcileTenantBootstrap(client, credentials); err != nil {
return err
}
log.Printf("tenant bootstrap credentials reconciled")
return nil
}
func (db *Database) GetMysql() *sql.DB {
return db.mysql
}
func ensureMySQLDatabase(parsedDsn *mysql.Config) error {
if parsedDsn == nil {
return errors.New("mysql dsn is nil")
}
if parsedDsn.DBName == "" {
return errors.New("mysql database name is empty")
}
adminDsn := parsedDsn.Clone()
dbName := adminDsn.DBName
adminDsn.DBName = ""
client, err := sql.Open("mysql", adminDsn.FormatDSN())
if err != nil {
return err
}
defer func() {
_ = client.Close()
}()
if err := client.Ping(); err != nil {
return err
}
View on GitHub (pinned to 5e758547a8)