Repository navigation
fix(admin): expose the instance record id in the instance API (#7731) - #7742
Conversation
Aias00
left a comment
There was a problem hiding this comment.
LGTM. The VO really had no id, and the DO→VO conversion is the single chokepoint for list, detail and paging, so one line fixes all three surfaces.
Evidence
InstanceInfoVOpreviously exposed ip/port/type/info/namespaceId/state/dates/heartbeat and nothing else;buildInstanceInfoVOcopied every persisted field except the key. The dashboard keying rows byitem.idtherefore receivedundefined, as reported.createOrUpdatebuilds its lookup from ip/port/type/namespace and itsupdateByIdfrom the DO it fetched, so addingidto the VO changes nothing on the write path.- The controller overlay in
queryPluginsonly replaces heartbeat time/state/updated time, so the persisted id survives the enrich step, as the PR body says. - The tests assert both the JSON contract (
dataList[0].id,data.id) and distinctness of two records, which is the property the dashboard actually needs.
Cross-PR note (please act on it)
#7749 (already approved) adds a manual copyInstanceInfoVO in InstanceCheckService that enumerates all nine VO fields — it predates this field. After both merge that copy will leave id null. It is harmless today because createOrUpdate never reads the VO id, but if #7749 lands second, please add copy.setId(vo.getId()) there so the "complete copy" invariant stays true.
Nit: serialVersionUID stays unchanged although the class gained a field — fine for a VO that is never deserialized from a stream, just noting it in case anyone expects strict compatibility.
|
Thanks for the cross-PR catch. On |
Fixes #7731.
Summary
InstanceInfoVOhas noidproperty andInstanceInfoServiceImpl#buildInstanceInfoVOcopies all persisted fields except the primary key. Both the instance list and detail endpoints use that conversion, so the dashboard'sitem.key = item.idreceives an undefined value and table row selection has no stable key.Modifications
idfield (with getter/setter) toInstanceInfoVO.Verifying this change
New
InstanceInfoServiceImplTest:findByIdpropagates the record id;listByPageexposes distinct non-empty ids for two records.InstanceControllerTest: assertsdataList[0].id/dataList[1].idin the list JSON anddata.idin the detail JSON.Red-green: removing the conversion line makes the service tests fail with a null id; restoring it passes (service 2/2, controller 4/4).
Targeted tests pass:
./mvnw -B -ntp -pl shenyu-admin test -Dtest=InstanceInfoServiceImplTest,InstanceControllerTest6/6 green.
Checkstyle passes:
clean.
Notes
The dashboard already keys instance rows by
item.id, so this backend change is sufficient; no dashboard change is included. Live heartbeat-map overlays in the controller only replace heartbeat time/state/update time, leaving the persisted id intact.