{"record":{"id":"b9ff03751e66ab12","repo":"iflytek/astron-agent","slug":"log-file-is-required","errorCode":null,"errorMessage":"log file is required","messagePattern":"log file is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/tenant/config/config.go","lineNumber":51,"sourceCode":"\nfunc (c *Config) Validate() error {\n\tif c.Server.Port == 0 {\n\t\treturn fmt.Errorf(\"server port is required\")\n\t}\n\tif c.DataBase.DBType == \"\" {\n\t\treturn fmt.Errorf(\"database type is required\")\n\t}\n\tif c.DataBase.UserName == \"\" {\n\t\treturn fmt.Errorf(\"database username is required\")\n\t}\n\tif c.DataBase.Password == \"\" {\n\t\treturn fmt.Errorf(\"database password is required\")\n\t}\n\tif c.DataBase.Url == \"\" {\n\t\treturn fmt.Errorf(\"database url is required\")\n\t}\n\tif c.Log.LogFile == \"\" {\n\t\treturn fmt.Errorf(\"log file is required\")\n\t}\n\treturn nil\n}\n\nfunc LoadConfig(path string) (*Config, error) {\n\tcfg := &Config{}\n\t// load config from local file\n\tlocalLoader := NewLocalLoader(path)\n\tif err := localLoader.Load(cfg); err != nil {\n\t\tfmt.Printf(\"failed to load config from file: %v\\n\", err)\n\t}\n\t// load config from environment variables\n\tenvLoader := NewEnvLoader()\n\tif err := envLoader.Load(cfg); err != nil {\n\t\treturn nil, err\n\t}\n\treturn cfg, cfg.Validate()\n}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/tenant/config/config.go#L33-L69","documentation":"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.","triggerScenarios":"LoadConfig(path) -> Config.Validate() returns this when `[log] path` is missing in the TOML and LOG_PATH is unset/empty.","commonSituations":"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.","solutions":["Set LOG_PATH in the environment (e.g. LOG_PATH=/var/log/tenant/tenant.log).","Add a [log] section with `path = \"...\"` to the TOML config file.","Verify the env var name is exactly LOG_PATH (not LOG_FILE or LOGFILE).","Ensure the configured directory exists and is writable by the service user, otherwise later log initialization will fail."],"exampleFix":"// before\n[database]\ndbType = \"postgres\"\n// after\n[database]\ndbType = \"postgres\"\n\n[log]\npath = \"/var/log/tenant/tenant.log\"","handlingStrategy":"validation","validationCode":"if os.Getenv(\"LOG_PATH\") == \"\" {\n\treturn errors.New(\"LOG_PATH must be set (e.g. /var/log/tenant/tenant.log) before startup\")\n}","typeGuard":null,"tryCatchPattern":"cfg, err := config.LoadConfig(path)\nif err != nil {\n\tif strings.Contains(err.Error(), \"log file is required\") {\n\t\tlog.Fatalf(\"LOG_PATH not set: %v\", err)\n\t}\n\treturn err\n}","preventionTips":["Always define a [log] section with `path` in service config files","Set LOG_PATH in container env and ensure the directory is mounted writable","Use the exact var name LOG_PATH — not LOG_FILE/LOGFILE","Include the log path in deployment checklists/CI config validation"],"tags":["configuration","logging","go","tenant-service"],"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-15T23:17:13.987Z"}