iflytek/astron-agent · error
mysql url is empty
Error message
mysql url is empty
What it means
parseMysqlConfig validates the MySQL section of the tenant service config before building a DSN. It throws 'mysql url is empty' when conf.DataBase.Url has zero length. The URL is the host:port portion used to assemble the go-sql-driver DSN (`user:pass@tcp<url>`), so without it no connection can be attempted.
Solutions
- Set database.url in the tenant config (or the mapped env var) to a host:port value such as "127.0.0.1:3306" or "mysql:3306".
- Verify the config file actually being loaded is the one you edited (check config load path logged at startup).
- Confirm the env-var binding for the URL field is present in the deployment manifest and reachable in the container.
- Check surrounding fields: the same validator also requires username and password, so fill all three together.
Example fix
// before (config.yaml) database: username: tenant password: secret # url missing // after database: username: tenant password: secret url: "mysql:3306"
Defensive patterns
Strategy: validation
Validate before calling
func validateMysqlConfig(conf *config.Config) error {
if conf.DataBase.Url == "" {
return errors.New("database.url must be set (host:port), e.g. mysql:3306")
}
return nil
}
// call before buildMysql Prevention
- Keep a validated example config file in the repo and validate configs in CI before deploy.
- Add a startup preflight that logs all required database fields (redacted) before connecting.
- Use a config schema (envconfig/viper required tags) so missing fields fail with a clear message.
When it happens
Trigger: parseMysqlConfig (via buildMysql) runs with conf.DataBase.Url == "" — e.g. the config file omits database.url or the corresponding env var mapping is unset/unbound.
Common situations: Fresh deployments where the mysql host env var was never set; docker-compose/Helm values.yaml missing database.url; typo'd config key so the field fails to populate; running the tenant service locally without a config file.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- mysql username is empty
- database config is nil or dbType is empty
- mysql password is empty
- mysql database name is empty
- check tenant bootstrap managed credential failed
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/561255277064e582.
Report an issue: GitHub.
Appendix: source
Thrown at core/tenant/tools/database/database.go:80
if err := initializeMysqlClient(client, conf.TenantBootstrap); err != nil {
_ = client.Close()
return err
}
db.mysql = client
return nil
}
func parseMysqlConfig(conf *config.Config) (string, *mysql.Config, error) {
if len(conf.DataBase.UserName) == 0 {
return "", nil, errors.New("mysql username is empty")
}
if len(conf.DataBase.Password) == 0 {
return "", nil, errors.New("mysql password is empty")
}
if len(conf.DataBase.Url) == 0 {
return "", nil, errors.New("mysql url is empty")
}
if err := conf.TenantBootstrap.Validate(); err != nil {
return "", nil, fmt.Errorf("invalid tenant bootstrap credentials: %w", err)
}
dsn := fmt.Sprintf("%s:%s@tcp%s", conf.DataBase.UserName, conf.DataBase.Password, conf.DataBase.Url)
parsedDsn, err := mysql.ParseDSN(dsn)
if err != nil {
return "", nil, err
}
return dsn, parsedDsn, nil
}
func initializeMysqlClient(
client *sql.DB,
credentials config.TenantBootstrapCredentials,
) error {
if err := runMigrations(client); err != nil {View on GitHub (pinned to 5e758547a8)