From 843a81f68da8a4c94006f9289fd86c5770bc9074 Mon Sep 17 00:00:00 2001 From: hkfires <10558748+hkfires@users.noreply.github.com> Date: Sat, 11 Oct 2025 22:07:08 +0800 Subject: [PATCH 1/2] fix(server): Handle empty/invalid config in cloud deploy mode --- cmd/server/main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index 0e0229e7..2abc5a15 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -122,15 +122,20 @@ func main() { log.Fatalf("failed to load config: %v", err) } - // Log if we're running without a config file in cloud deploy mode + // In cloud deploy mode, check if we have a valid configuration var configFileExists bool if isCloudDeploy { if info, errStat := os.Stat(configFilePath); errStat != nil { // Don't mislead: API server will not start until configuration is provided. - log.Info("Cloud deploy mode: No configuration file detected; standing by for configuration (API server not started)") + log.Info("Cloud deploy mode: No configuration file detected; standing by for configuration") configFileExists = false } else if info.IsDir() { - log.Info("Cloud deploy mode: Config path is a directory; standing by for configuration (API server not started)") + log.Info("Cloud deploy mode: Config path is a directory; standing by for configuration") + configFileExists = false + } else if cfg.Port == 0 { + // LoadConfigOptional returns empty config when file is empty or invalid. + // Config file exists but is empty or invalid; treat as missing config + log.Info("Cloud deploy mode: Configuration file is empty or invalid; standing by for valid configuration") configFileExists = false } else { log.Info("Cloud deploy mode: Configuration file detected; starting service") From 4c033b3af74d89dc9ddd488b198cd9083e4c4c1a Mon Sep 17 00:00:00 2001 From: hkfires <10558748+hkfires@users.noreply.github.com> Date: Sat, 11 Oct 2025 22:11:08 +0800 Subject: [PATCH 2/2] feat(config): disable logging and usage stats by default --- internal/config/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 1d9fca20..3de596a7 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -180,8 +180,8 @@ func LoadConfigOptional(configFile string, optional bool) (*Config, error) { // Unmarshal the YAML data into the Config struct. var cfg Config // Set defaults before unmarshal so that absent keys keep defaults. - cfg.LoggingToFile = true - cfg.UsageStatisticsEnabled = true + cfg.LoggingToFile = false + cfg.UsageStatisticsEnabled = false if err = yaml.Unmarshal(data, &cfg); err != nil { if optional { // In cloud deploy mode, if YAML parsing fails, return empty config instead of error.