Skip to content

feat: merge device on duplicate post - #1283

Open
amarnath-ac wants to merge 1 commit into
mainfrom
console_rps_upsert
Open

amarnath-ac wants to merge 1 commit into
mainfrom
console_rps_upsert

Conversation

@amarnath-ac

@amarnath-ac amarnath-ac commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.80%. Comparing base (6ab185c) to head (20f0831).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@amarnath-ac amarnath-ac changed the title feat: merge device on duplicate post (#675) feat: merge device on duplicate post Sep 23, 2026
@amarnath-ac
amarnath-ac requested a lite review from Copilot September 23, 2026 11:55
Device POST upserts: on a duplicate GUID, merge the supplied fields
into the stored device and return 200 instead of 409.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 High severity

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)
@sudhir-intc

Copy link
Copy Markdown
Contributor

@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

@rsdmike

rsdmike commented Sep 23, 2026

Copy link
Copy Markdown
Member

Thanks for this, brings it more in line with MPS. Few things i see:

  1. While this is technicaly a breaking change for console -- it matches MPS, so i think thats good. I would just call that out a bit more clearly in the commit/description.
  2. I don't think 404 makes sense, mps is 400, but 409 would work too. the main issue is that the search needs to be across tenants since the GUIDs need to be unique.
  3. there is some differences in how MPS handles this vs console in regards to what fields are getting updated. It might be worth an exercise to see where we need to update MPS. For example, MPS does a replace on deviceinfo, console is merging (i think). Aligning them would be ideal.

@amarnath-ac

amarnath-ac commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

@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

@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.

@amarnath-ac

Copy link
Copy Markdown
Contributor Author

Thanks for this, brings it more in line with MPS. Few things i see:

  1. While this is technicaly a breaking change for console -- it matches MPS, so i think thats good. I would just call that out a bit more clearly in the commit/description.
  2. I don't think 404 makes sense, mps is 400, but 409 would work too. the main issue is that the search needs to be across tenants since the GUIDs need to be unique.
  3. there is some differences in how MPS handles this vs console in regards to what fields are getting updated. It might be worth an exercise to see where we need to update MPS. For example, MPS does a replace on deviceinfo, console is merging (i think). Aligning them would be ideal.

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants