mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-19 00:56:16 +00:00
Closes issue #285. When the user renames an ST10 via the Bose App or via `soundtouch-cli name set`, the speaker fires: PUT http://<aftertouch>:8000/streaming/account/{accountID}/device/{deviceID} Content-Type: application/xml <device deviceid="…"><name>NEW</name><macaddress>…</macaddress></device> The router only had POST registered for that path; PUT fell through to chi's default handling and the speaker observed HTTP 502 (captured verbatim in _/i285/Rename.log:38: "SimpleURLFetcher: retry needed, Curl 0, http 502, retries remaining 0"). The speaker's SimpleURLFetcher retried the PUT on a 15-second timer, the Bose App showed the rename spinning indefinitely, and the device's display name never updated on the AfterTouch side. Implementation reuses marge.AddDeviceToAccount, which is already an upsert via ds.SaveDeviceInfo — there's no semantic difference between "add" and "update" at the persistence layer. The new handler HandleMargeUpdateDevice differs from HandleMargeAddDevice only in the HTTP envelope: - 200 OK (not 201 Created — this is an update, not a fresh resource) - no Location header (the resource already lives at the URL the speaker is PUT-ing to) - deviceID in the body must match the URL's {device} segment; mismatch is a 400 rather than a silent re-key Registered as `r.Put("/{device}", server.HandleMargeUpdateDevice)` inside the existing `/streaming/account/{account}/device/` route group in both cmd/soundtouch-service/main.go and the handlers-package test router. Router-routes snapshot regenerated. Test coverage in pkg/service/handlers/issue285_regression_test.go: - TestIssue285_RenamePutAcceptedAndPersisted seeds the datastore with a device under its original name, replays the literal log payload from _/i285/Rename.log:36 against the real router, and asserts 200 OK + new name in response body + new name persisted on disk. testdata/issue285/rename_request.xml is the captured payload byte-for-byte (accountID 3981561, deviceID 884AEAEEBD27, rename to "Wohnzimmer SB" — same as the reporter). - TestIssue285_RenamePutRejectsMismatchedDeviceID pins the safety check: body deviceid != URL {device} → 400. Closes #285. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>