Skip to content

refactor: map additional device export fields - #1233

Open
sinchubhat wants to merge 1 commit into
device-discovery-exportAPIfrom
issue1513-rpc-go
Open

refactor: map additional device export fields#1233
sinchubhat wants to merge 1 commit into
device-discovery-exportAPIfrom
issue1513-rpc-go

Conversation

@sinchubhat

@sinchubhat sinchubhat commented Sep 1, 2026

Copy link
Copy Markdown
Contributor
  • persist ME and OS network details from rpc-go sync
  • map OS DNS suffix and platform adapters into export output
  • preserve fallback mapping for legacy flat IP fields
  • map the existing AMT BIOS state to the export MEBX field

Addresses device-management-toolkit/rpc-go#1513

Dependencies

Implementation Details:

Field Console export / mapping behavior
deviceInfo.dnsSuffixOS Stored on DeviceInfo and exported as deviceInfo.os.dnsSuffix
deviceInfo.meNetwork.wired Exported as deviceInfo.me.network.wired when at least one wired ME interface field is present
deviceInfo.meNetwork.wireless Exported as deviceInfo.me.network.wireless when at least one wireless ME interface field is present
deviceInfo.meNetwork.*.ipAddress Exported to deviceInfo.me.network.*.ipAddress
deviceInfo.meNetwork.*.dhcpEnabled Exported to deviceInfo.me.network.*.dhcpEnabled
deviceInfo.meNetwork.*.dhcpMode Exported to deviceInfo.me.network.*.dhcpMode
deviceInfo.meNetwork.*.linkStatus Exported to deviceInfo.me.network.*.linkStatus
deviceInfo.meNetwork.*.macAddress Exported to deviceInfo.me.network.*.macAddress
legacy deviceInfo.ipAddress / deviceInfo.dhcpEnabled Used as ME wired network fallback when nested meNetwork is absent or empty
deviceInfo.osNetwork.wired[] Exported as deviceInfo.os.network.wired[]; empty wired interface objects are ignored
deviceInfo.osNetwork.wireless Exported as deviceInfo.os.network.wireless when at least one wireless OS interface field is present
deviceInfo.osNetwork.*.name Exported to deviceInfo.os.network.*.name
deviceInfo.osNetwork.*.ipAddress Exported to deviceInfo.os.network.*.ipAddress
deviceInfo.osNetwork.*.dhcpEnabled Exported to deviceInfo.os.network.*.dhcpEnabled; may be null when rpc-go cannot determine DHCP state
deviceInfo.osNetwork.*.linkStatus Exported to deviceInfo.os.network.*.linkStatus
deviceInfo.osNetwork.*.macAddress Exported to deviceInfo.os.network.*.macAddress
legacy deviceInfo.osIpAddress Used as OS wired network fallback when nested osNetwork is absent or empty
deviceInfo.platformAdapters.wired Exported as deviceInfo.platform.adapters.wired when non-empty
deviceInfo.platformAdapters.wireless Exported as deviceInfo.platform.adapters.wireless when non-empty
deviceInfo.ethernetAdapterCount Exported as deviceInfo.platform.ethernetAdapterCount
deviceInfo.amtEnabledInBIOS Exported as deviceInfo.me.mebxEnabledInBIOS; no duplicate mebxEnabledInBIOS storage field is added
Empty meNetwork / osNetwork objects Suppressed so empty nested objects do not create fake ME/OS subsystems
Non-AMT or VM devices Can export OS/platform data while deviceInfo.me remains null

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.22034% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.83%. Comparing base (20b39a8) to head (56d646e).

Files with missing lines Patch % Lines
internal/usecase/devices/usecase.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                       @@
##           device-discovery-exportAPI    #1233      +/-   ##
==============================================================
+ Coverage                       56.67%   56.83%   +0.16%     
==============================================================
  Files                             150      150              
  Lines                           12339    12392      +53     
==============================================================
+ Hits                             6993     7043      +50     
- Misses                           5345     5348       +3     
  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.

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.

🟡 Changes recommended

The export shaping currently contains a non-compiling struct type conversion and a couple of export-presence/mapping edge cases that can drop or emit empty subsystems incorrectly.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Extends the /api/v1/devices/export shaping to include additional OS/ME/platform network-related fields being synced from rpc-go, while preserving legacy fallback behavior for flat IP fields.

Changes:

  • Adds nested DTO fields for OS DNS suffix, ME/OS network details, and platform adapter names on DeviceInfo.
  • Updates export shaping to emit ME/OS network structures (with legacy fallback to flat IP fields) and platform adapters.
  • Extends export endpoint test coverage to validate the newly-exported fields.
File summaries
File Description
internal/usecase/devices/usecase.go Adds merge/setter keys for new device-info fields so partial updates can persist them.
internal/entity/dto/v1/device.go Introduces new nested DeviceInfo DTO fields/types for OS DNS suffix, ME/OS network, and platform adapters.
internal/controller/httpapi/v1/export.go Maps the new nested fields into the export response while retaining legacy fallbacks.
internal/controller/httpapi/v1/export_test.go Adds assertions for DNS suffix, interface metadata, and platform adapters in export output.
Review details

Suppressed comments (1)

internal/controller/httpapi/v1/export.go:224

  • buildExportOS decides whether to emit the OS subsystem using hasOS, but it doesn't include the newly-added DNSSuffixOS or OSNetwork fields. If those are the only OS details present, the OS subsystem will incorrectly render as null even though data exists.
	hasOS := info.OSName != "" || info.OSVersion != "" || info.OSDistro != "" ||
		info.OSIPAddress != "" || info.LMSInstalled != nil || info.LMSVersion != "" ||
		info.MEInterfaceVersion != "" || info.MonitorConnected != nil || info.IEEE8021XEnabled != nil
	if !hasOS {
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/controller/httpapi/v1/export.go
Comment thread internal/controller/httpapi/v1/export.go Outdated

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.

🟡 Changes recommended

The export mapping currently skips legacy IP fallbacks (and can suppress OS export entirely) when nested network/dns fields are present-but-empty or are the only OS data, which contradicts the intended backward-compatible behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

internal/controller/httpapi/v1/export.go:242

  • Same fallback issue as ME: if info.OSNetwork is non-nil but empty, buildExportOSNetwork returns nil and the legacy OSIPAddress fallback is skipped, resulting in a missing OS network in the export. Only prefer the nested mapping when it yields a non-nil export network.
	if info.OSNetwork != nil {
		osInfo.Network = buildExportOSNetwork(info.OSNetwork)
	} else if info.OSIPAddress != "" {
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread internal/controller/httpapi/v1/export.go Outdated
Comment thread internal/controller/httpapi/v1/export.go

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.

🟡 Changes recommended

buildExportOS currently treats an empty-but-non-nil osNetwork object as OS presence, which can cause an “empty” OS subsystem to be exported instead of null when no OS data was actually reported.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread internal/controller/httpapi/v1/export.go Outdated
@sinchubhat
sinchubhat force-pushed the issue1513-rpc-go branch 2 times, most recently from 0062372 to 837de43 Compare September 3, 2026 05:04
@sinchubhat
sinchubhat requested a lite review from Copilot September 3, 2026 05:15

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.

🟡 Changes recommended

The new 1:1 struct-literal mappings in export.go are likely to fail CI due to staticcheck S1016 and should be replaced with direct struct conversions.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

internal/controller/httpapi/v1/export.go:298

  • This 1:1 field-copy struct literal is a candidate for staticcheck S1016. Since OSInterfaceInfo and ExportOSInterface have identical fields, prefer a direct conversion to avoid lint failures and reduce boilerplate.
	return &dto.ExportOSInterface{
		Name:        adapter.Name,
		IPAddress:   adapter.IPAddress,
		DHCPEnabled: adapter.DHCPEnabled,
		LinkStatus:  adapter.LinkStatus,
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread internal/controller/httpapi/v1/export.go Outdated
@sinchubhat
sinchubhat marked this pull request as ready for review September 3, 2026 05:42
@sinchubhat
sinchubhat requested a review from a team as a code owner September 3, 2026 05:42
* persist ME and OS network details from rpc-go sync
* map OS DNS suffix and platform adapters into export output
* preserve fallback mapping for legacy flat IP fields
* map the existing AMT BIOS state to the export MEBX field

Addresses device-management-toolkit/rpc-go#1513
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.

Send missing OS/ME network adapter and DNS suffix fields required by Console export API

2 participants