Skip to content

Prefer fetch-api device definition documents over DB fields#178

Open
elffjs wants to merge 2 commits intomainfrom
claude/migrate-vehicle-definitions-3cg7R
Open

Prefer fetch-api device definition documents over DB fields#178
elffjs wants to merge 2 commits intomainfrom
claude/migrate-vehicle-definitions-3cg7R

Conversation

@elffjs
Copy link
Copy Markdown
Member

@elffjs elffjs commented Mar 29, 2026

When resolving the Definition field on a Vehicle, first check the
fetch-api gRPC service for a stored cloud event with subject equal to
the vehicle's DID and type "dimo.document.devicedefinition". If found,
the JSON data payload (tableland column key-value pairs) takes precedence
over the make/model/year/id values stored in the DB.

Falls back to DB values when:

  • FETCH_API_GRPC_ADDR is not configured
  • No document exists in fetch-api for the vehicle DID
  • Any fetch-api error occurs (logged as a warning)

Changes:

  • internal/fetchapi/: vendored proto-generated gRPC client types from
    github.com/DIMO-Network/fetch-api/pkg/grpc (package renamed to fetchapi
    to avoid import aliasing issues)
  • internal/services/fetch_api_service.go: new gRPC client wrapping
    GetLatestCloudEvent with subject/type filtering
  • internal/config/settings.go: add FETCH_API_GRPC_ADDR setting
  • internal/repositories/vehicle/vehicles.go: inject FetchAPIService,
    enrich Definition from fetch-api in GetVehicle and GetVehicles
  • graph/resolver.go: wire up FetchAPIService using settings addr
  • go.mod/go.sum: add google.golang.org/grpc v1.78.0

https://claude.ai/code/session_019HRD1qSgtK9yEo6D4W34Vw

claude and others added 2 commits March 29, 2026 14:08
When resolving the Definition field on a Vehicle, first check the
fetch-api gRPC service for a stored cloud event with subject equal to
the vehicle's DID and type "dimo.document.devicedefinition". If found,
the JSON data payload (tableland column key-value pairs) takes precedence
over the make/model/year/id values stored in the DB.

Falls back to DB values when:
- FETCH_API_GRPC_ADDR is not configured
- No document exists in fetch-api for the vehicle DID
- Any fetch-api error occurs (logged as a warning)

Changes:
- internal/fetchapi/: vendored proto-generated gRPC client types from
  github.com/DIMO-Network/fetch-api/pkg/grpc (package renamed to fetchapi
  to avoid import aliasing issues)
- internal/services/fetch_api_service.go: new gRPC client wrapping
  GetLatestCloudEvent with subject/type filtering
- internal/config/settings.go: add FETCH_API_GRPC_ADDR setting
- internal/repositories/vehicle/vehicles.go: inject FetchAPIService,
  enrich Definition from fetch-api in GetVehicle and GetVehicles
- graph/resolver.go: wire up FetchAPIService using settings addr
- go.mod/go.sum: add google.golang.org/grpc v1.78.0

https://claude.ai/code/session_019HRD1qSgtK9yEo6D4W34Vw
Route fetch-api device definition enrichment through request-scoped vehicle loading instead of the vehicle repository.

- restore the vehicle repository to DB-only behavior
- add a vehicle definition fetcher interface plus shared overlay helper
- enrich batched vehicle loads with bounded concurrency and fallback logging
- keep top-level vehicle queries consistent by reusing the same enrichment helper
- update middleware wiring and add tests for override/fallback and query-shape consistency
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.

2 participants