feat: merge device on duplicate post - #1283
amarnath-ac wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1283 +/- ##
==========================================
+ Coverage 60.73% 60.80% +0.07%
==========================================
Files 151 151
Lines 12632 12653 +21
==========================================
+ Hits 7672 7694 +22
+ Misses 4959 4958 -1
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
113fd32 to
20f0831
Compare
Device POST upserts: on a duplicate GUID, merge the supplied fields into the stored device and return 200 instead of 409.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Address the concurrent merge race and normalize empty tags to preserve the response contract.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Updates POST /api/v1/devices to merge supplied fields on duplicate GUIDs and return 200 OK.
Changes:
- Adds duplicate detection and partial update handling.
- Documents the new response behavior.
- Adds unit and Postman coverage.
| File | Summary |
|---|---|
internal/controller/openapi/devices.go |
Documents duplicate-GUID merge behavior and 200 OK. |
internal/controller/httpapi/v1/devices.go |
Implements duplicate handling. Critical (1 vote): concurrent merges can lose fields. Moderate (1 vote): empty tags may serialize as null instead of []. |
internal/controller/httpapi/v1/devices_test.go |
Adds upsert and error-path tests. |
integration-test/collections/console_mps_apis.postman_collection.json |
Adds repeat-POST integration coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| return | ||
| } | ||
|
|
||
| updatedDevice, err := dr.t.Update(c.Request.Context(), device, fields) |
|
@amarnath-ac : Can you provide the context for this change ? I don't see any github issue too linked to understand why this feature is needed |
|
Thanks for this, brings it more in line with MPS. Few things i see:
|
@sudhir-intc, Main github issue, sub-task and ADR, these issues are in deployment repo so was not able to link issue in commit message. |
@rsdmike, Thanks for the review, I will update the commit description with more details and i was not able to link the issue since issue is in deployment repo. And i will address other comments. |

Device POST upserts: on a duplicate GUID, merge the supplied fields into the stored device and return 200 instead of 409.
Github issue and ADR