iflytek/astron-agent · error

log file is required

Error message

log file is required

What it means

Config.Validate requires Log.LogFile to be non-empty; this error means the log output path was never configured, so the tenant service cannot initialize its file logging. Sources are the TOML `[log] path` key and the LOG_PATH env var; this is the last required-field check in Validate.

Solutions

  1. Set LOG_PATH in the environment (e.g. LOG_PATH=/var/log/tenant/tenant.log).
  2. Add a [log] section with `path = "..."` to the TOML config file.
  3. Verify the env var name is exactly LOG_PATH (not LOG_FILE or LOGFILE).
  4. Ensure the configured directory exists and is writable by the service user, otherwise later log initialization will fail.

Example fix

// before
[database]
dbType = "postgres"
// after
[database]
dbType = "postgres"

[log]
path = "/var/log/tenant/tenant.log"
Defensive patterns

Strategy: validation

Validate before calling

if os.Getenv("LOG_PATH") == "" {
	return errors.New("LOG_PATH must be set (e.g. /var/log/tenant/tenant.log) before startup")
}

Try / catch

cfg, err := config.LoadConfig(path)
if err != nil {
	if strings.Contains(err.Error(), "log file is required") {
		log.Fatalf("LOG_PATH not set: %v", err)
	}
	return err
}

Prevention

When it happens

Trigger: LoadConfig(path) -> Config.Validate() returns this when `[log] path` is missing in the TOML and LOG_PATH is unset/empty.

Common situations: Config file lacking a [log] section, container images/deployments that rely on stdout only and never set LOG_PATH, or renaming LOGFILE/LOG_FILE instead of the expected LOG_PATH.

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


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/b9ff03751e66ab12. Report an issue: GitHub.

Appendix: source

Thrown at core/tenant/config/config.go:51

func (c *Config) Validate() error {
	if c.Server.Port == 0 {
		return fmt.Errorf("server port is required")
	}
	if c.DataBase.DBType == "" {
		return fmt.Errorf("database type is required")
	}
	if c.DataBase.UserName == "" {
		return fmt.Errorf("database username is required")
	}
	if c.DataBase.Password == "" {
		return fmt.Errorf("database password is required")
	}
	if c.DataBase.Url == "" {
		return fmt.Errorf("database url is required")
	}
	if c.Log.LogFile == "" {
		return fmt.Errorf("log file is required")
	}
	return nil
}

func LoadConfig(path string) (*Config, error) {
	cfg := &Config{}
	// load config from local file
	localLoader := NewLocalLoader(path)
	if err := localLoader.Load(cfg); err != nil {
		fmt.Printf("failed to load config from file: %v\n", err)
	}
	// load config from environment variables
	envLoader := NewEnvLoader()
	if err := envLoader.Load(cfg); err != nil {
		return nil, err
	}
	return cfg, cfg.Validate()
}

View on GitHub (pinned to 5e758547a8)