Fix concurrent map write issue in MarshalJSON by initializing BackendOptions

This commit is contained in:
2025-10-27 20:36:42 +01:00
parent 5b84b64623
commit f9eb424690

View File

@@ -93,6 +93,8 @@ func (o *Options) MarshalJSON() ([]byte, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to marshal backend options: %w", err) return nil, fmt.Errorf("failed to marshal backend options: %w", err)
} }
// Create a new map to avoid concurrent map writes
aux.BackendOptions = make(map[string]any)
if err := json.Unmarshal(optionsData, &aux.BackendOptions); err != nil { if err := json.Unmarshal(optionsData, &aux.BackendOptions); err != nil {
return nil, fmt.Errorf("failed to unmarshal backend options to map: %w", err) return nil, fmt.Errorf("failed to unmarshal backend options to map: %w", err)
} }