iflytek/astron-agent · error

invalid DATABASE_MAX_IDLE_CONNS

Error message

invalid DATABASE_MAX_IDLE_CONNS: %v

What it means

EnvLoader.setDatabaseMaxIdleConns parses DATABASE_MAX_IDLE_CONNS with fmt.Sscanf("%d") and returns this error when the value is non-empty but not a valid integer. The value configures the DB pool's maximum idle connections, and the error aborts startup via LoadConfig -> EnvLoader.Load.

Solutions

  1. Set DATABASE_MAX_IDLE_CONNS to a plain integer (e.g. DATABASE_MAX_IDLE_CONNS=10) and restart.
  2. Inspect with `printenv DATABASE_MAX_IDLE_CONNS | cat -A` and remove stray text/units from the manifest.
  3. Keep idle conns a plain integer <= max open conns; drop any floats or units.
  4. Optionally switch the loader to strconv.Atoi for clearer parse errors.

Example fix

// before
DATABASE_MAX_IDLE_CONNS=10 idle
// after
DATABASE_MAX_IDLE_CONNS=10
Defensive patterns

Strategy: validation

Validate before calling

if v := os.Getenv("DATABASE_MAX_IDLE_CONNS"); v != "" {
	if n, err := strconv.Atoi(v); err != nil || n < 0 {
		return fmt.Errorf("DATABASE_MAX_IDLE_CONNS must be a non-negative integer, got %q", v)
	}
}

Try / catch

_, err := config.LoadConfig(path)
if err != nil && strings.HasPrefix(err.Error(), "invalid DATABASE_MAX_IDLE_CONNS") {
	log.Fatalf("DATABASE_MAX_IDLE_CONNS=%q is not an integer: %v", os.Getenv("DATABASE_MAX_IDLE_CONNS"), err)
}

Prevention

When it happens

Trigger: DATABASE_MAX_IDLE_CONNS is set (non-empty) but unparseable as an integer: e.g. "10idle", "ten", "10.5", or a value with hidden whitespace/control characters at the start.

Common situations: Appending units or comments to pool-size numbers in deployment manifests, YAML type coercion issues, hand-edited .env files with typos, or copy-pasting values with trailing descriptions.

Understand the failure class

Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.

Related errors


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

Appendix: source

Thrown at core/tenant/config/env_loader.go:84

	cfg.DataBase.Password = value
	return nil
}

func (l *EnvLoader) setDatabaseURL(cfg *Config, value string) error {
	cfg.DataBase.Url = value
	return nil
}

func (l *EnvLoader) setDatabaseMaxOpenConns(cfg *Config, value string) error {
	if n, err := fmt.Sscanf(value, "%d", &cfg.DataBase.MaxOpenConns); err != nil || n != 1 {
		return fmt.Errorf("invalid DATABASE_MAX_OPEN_CONNS: %v", err)
	}
	return nil
}

func (l *EnvLoader) setDatabaseMaxIdleConns(cfg *Config, value string) error {
	if n, err := fmt.Sscanf(value, "%d", &cfg.DataBase.MaxIdleConns); err != nil || n != 1 {
		return fmt.Errorf("invalid DATABASE_MAX_IDLE_CONNS: %v", err)
	}
	return nil
}

func (l *EnvLoader) setLogPath(cfg *Config, value string) error {
	cfg.Log.LogFile = value
	return nil
}

func (l *EnvLoader) Watch(cfg *Config, onChange func()) {
}

View on GitHub (pinned to 5e758547a8)