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).
This commit is contained in:
1 parent
479ed95a91
commit
3802ed473d
1 file changed
+12
@@ -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...)
|
||||
|
||||
Reference in new issue
Block a user