Problem
RenameDevice fetches the full device list, finds the right device, but then only sends deviceID and name in the PUT body:
body, _ := json.Marshal(map[string]any{
"deviceID": d.DeviceID,
"name": name,
})
return c.put("/rest/config/devices/"+deviceID, body)
Syncthing's PUT /rest/config/devices/{id} replaces the entire device object. Any fields not included (addresses, compression, introducedBy, paused, etc.) get reset to defaults. This can silently break device configuration.
Fix
Instead of building a sparse map, marshal the full apiDevice struct with the name overridden:
d.Name = name
body, err := json.Marshal(d)
if err != nil {
return err
}
return c.put("/rest/config/devices/"+deviceID, body)
Note: apiDevice currently only has DeviceID and Name fields. It needs to be extended to capture all fields Syncthing returns so a round-trip PUT preserves them.
Problem
RenameDevicefetches the full device list, finds the right device, but then only sendsdeviceIDandnamein the PUT body:Syncthing's PUT
/rest/config/devices/{id}replaces the entire device object. Any fields not included (addresses, compression, introducedBy, paused, etc.) get reset to defaults. This can silently break device configuration.Fix
Instead of building a sparse map, marshal the full
apiDevicestruct with the name overridden:Note:
apiDevicecurrently only hasDeviceIDandNamefields. It needs to be extended to capture all fields Syncthing returns so a round-trip PUT preserves them.