Skip to content

Comments

feat: add rpc endpoint to list entities#485

Draft
paulstuart wants to merge 7 commits intodevelopfrom
feat-OBS-1811-list-entities
Draft

feat: add rpc endpoint to list entities#485
paulstuart wants to merge 7 commits intodevelopfrom
feat-OBS-1811-list-entities

Conversation

@paulstuart
Copy link
Contributor

Per OBS-1811

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Go test coverage

STATUS ELAPSED PACKAGE COVER PASS FAIL SKIP
🟢 PASS 1.52s github.com/netboxlabs/diode/diode-server/auth 44.7% 42 0 0
🟢 PASS 1.15s github.com/netboxlabs/diode/diode-server/auth/cli 0.0% 0 0 0
🟢 PASS 1.03s github.com/netboxlabs/diode/diode-server/authutil 82.8% 5 0 0
🟢 PASS 0.12s github.com/netboxlabs/diode/diode-server/dbstore/postgres 0.0% 0 0 0
🟢 PASS 1.09s github.com/netboxlabs/diode/diode-server/entityhash 86.7% 16 0 0
🟢 PASS 1.21s github.com/netboxlabs/diode/diode-server/entitymatcher 83.0% 91 0 0
🟢 PASS 0.24s github.com/netboxlabs/diode/diode-server/errors 0.0% 0 0 0
🟢 PASS 1.29s github.com/netboxlabs/diode/diode-server/ingester 82.7% 25 0 0
🟢 PASS 1.12s github.com/netboxlabs/diode/diode-server/matching 94.1% 66 0 0
🟢 PASS 1.07s github.com/netboxlabs/diode/diode-server/migrator 70.4% 4 0 0
🟢 PASS 4.19s github.com/netboxlabs/diode/diode-server/netboxdiodeplugin 83.6% 40 0 0
🟢 PASS 0.16s github.com/netboxlabs/diode/diode-server/pprof 0.0% 0 0 0
🟢 PASS 2.69s github.com/netboxlabs/diode/diode-server/reconciler 53.5% 147 0 0
🟢 PASS 1.02s github.com/netboxlabs/diode/diode-server/reconciler/applier 85.7% 1 0 0
🟢 PASS 0.12s github.com/netboxlabs/diode/diode-server/reconciler/changeset 0.0% 0 0 0
🟢 PASS 1.09s github.com/netboxlabs/diode/diode-server/reconciler/differ 63.8% 6 0 0
🟢 PASS 1.02s github.com/netboxlabs/diode/diode-server/server 85.7% 14 0 0
🟢 PASS 1.01s github.com/netboxlabs/diode/diode-server/strcase 100.0% 24 0 0
🟢 PASS 1.04s github.com/netboxlabs/diode/diode-server/telemetry 28.0% 26 0 0
🟢 PASS 1.03s github.com/netboxlabs/diode/diode-server/telemetry/otel 91.7% 25 0 0
🟢 PASS 0.14s github.com/netboxlabs/diode/diode-server/tls 0.0% 0 0 0
🟢 PASS 1.01s github.com/netboxlabs/diode/diode-server/version 100.0% 2 0 0

Total coverage: 56.1%

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds graph-backed RPC support in the reconciler service to list observed entities (and wires in graph DB access) as part of OBS-1811.

Changes:

  • Extend reconciler server construction to accept a GraphRepository dependency and gate graph RPCs when unavailable.
  • Implement ListEntities and CreateEntity graph endpoints plus ListGraphNodes repository/query support.
  • Update reconciler-related tests and reconciler main wiring to pass the new graph repository parameter.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
diode-server/reconciler/server_test.go Updates server construction in tests to provide a graph repository mock.
diode-server/reconciler/server.go Adds graph repository field/dependency and wires ListEntities/CreateEntity to new handlers.
diode-server/reconciler/mocks/graphrepository.go Extends the graph repository mock with ListGraphNodes.
diode-server/reconciler/graph_repository.go Extends GraphRepository interface with ListGraphNodes.
diode-server/reconciler/graph_endpoints.go New implementation for ListEntities and CreateEntity handlers and node→entity conversion.
diode-server/ingester/component_test.go Updates reconciler server startup helper to provide graph repository mock.
diode-server/gen/dbstore/postgres/graph.sql.go SQLC-generated code for ListGraphNodes.
diode-server/dbstore/postgres/queries/graph.sql Adds the ListGraphNodes SQL query definition.
diode-server/cmd/reconciler/main.go Wires SQLC queries as GraphRepository into reconciler server.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +34 to +36
// Generate new UUID for external ID
externalID := uuid.New().String()

Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

createEntity always generates a new UUID for externalID, so repeated calls with the same entity will create multiple rows (UpsertGraphNode only conflicts on (node_type, external_id)). This contradicts the RPC comment claiming idempotency and will inflate duplicates. Consider looking up an existing node first (e.g., by content hash/metadata) and reusing its external_id, or otherwise deriving a stable external_id for idempotency.

Copilot uses AI. Check for mistakes.
Comment on lines +98 to +102
// Parse page token (offset encoded as base64)
offset := int32(0)
if req.GetPageToken() != "" {
offsetBytes, err := base64.StdEncoding.DecodeString(req.GetPageToken())
if err != nil {
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

Pagination token handling here duplicates logic and uses a different encoding (base64 of an ASCII integer) than the existing deviation pagination helpers (binary int32 + base64 in deviation.go). This inconsistency makes client implementations harder and increases maintenance cost. Consider reusing a shared helper or aligning token formats across endpoints.

Copilot uses AI. Check for mistakes.
Comment on lines +88 to +92
func listEntities(ctx context.Context, graphdb GraphRepository, req *reconcilerpb.ListEntitiesRequest) (*reconcilerpb.ListEntitiesResponse, error) {
// Parse pagination parameters
pageSize := defaultPageSize
if req.GetPageSize() > 0 {
pageSize = int(req.GetPageSize())
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

New RPC behavior in createEntity/listEntities is added without unit tests. Please add tests using mocks.GraphRepository to cover pagination token parsing (valid/invalid), filter passthrough to ListGraphNodes, next page token generation, and create-entity idempotency/error paths.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant