Skip to content

bug: RenameDevice sends incomplete PUT body, resets device config fields #28

Description

@gitcoder89431

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions