fix(config): prevent panic by checking reflect.Value.IsValid() (#334)

This commit is contained in:
wy7681259
2025-09-11 09:49:12 +08:00
committed by GitHub
parent 246bea7bec
commit bc6b6a63d7

View File

@@ -239,10 +239,15 @@ func (config *Config) ParseUserFile(conf map[string]any) {
}
} else {
fv := prop.assign(k, v)
if fv.IsValid() {
prop.File = fv.Interface()
if prop.Env == nil {
prop.Ptr.Set(fv)
}
} else {
// continue invalid field
slog.Error("Attempted to access invalid field during config parsing: %s", v)
}
}
}
}