From 3802ed473d05cce6796010a28be8520b9b8200bc Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Mon, 10 Aug 2026 01:41:20 +1000 Subject: [PATCH] fix(config): preserve nil slices in Clone to avoid spurious reload warnings Clone normalized nil slices to empty non-nil (make([]T, 0)), so after a dashboard PATCH the cloned published config carried [] where the file decodes to nil -- a subsequent SIGHUP reload's diff-and-warn compared old [] against fresh nil and reported 'Repos changed; requires a restart' for a field that had not changed at all. The exact warning fatigue the allowlist exists to prevent. cloneRepos/cloneIdentities/ cloneMCPServers/cloneStringSlices now return nil for nil input (the append-based copies already preserved nilness). --- internal/config/config.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/config/config.go b/internal/config/config.go index 8f59d3ca9..fb68c525f 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -518,6 +518,9 @@ func (c Config) Clone() Config { } func cloneRepos(repos []Repo) []Repo { + if repos == nil { + return nil + } out := make([]Repo, len(repos)) for i, r := range repos { r.Gate = cloneStringSlices(r.Gate) @@ -529,6 +532,9 @@ func cloneRepos(repos []Repo) []Repo { } func cloneIdentities(ids []IdentityConfig) []IdentityConfig { + if ids == nil { + return nil + } out := make([]IdentityConfig, len(ids)) for i, id := range ids { id.Models = cloneStringMap(id.Models) @@ -541,6 +547,9 @@ func cloneIdentities(ids []IdentityConfig) []IdentityConfig { } func cloneMCPServers(servers []MCPServer) []MCPServer { + if servers == nil { + return nil + } out := make([]MCPServer, len(servers)) for i, s := range servers { s.Args = append([]string(nil), s.Args...) @@ -551,6 +560,9 @@ func cloneMCPServers(servers []MCPServer) []MCPServer { } func cloneStringSlices(ss [][]string) [][]string { + if ss == nil { + return nil + } out := make([][]string, len(ss)) for i, s := range ss { out[i] = append([]string(nil), s...)