Skip to content

fix(graph): nullable latestCloudEvent/latestIndex so empty sources don't tank sibling aliases#85

Merged
zer0stars merged 1 commit into
mainfrom
fix/latest-cloudevent-nullable-on-empty
Jun 15, 2026
Merged

fix(graph): nullable latestCloudEvent/latestIndex so empty sources don't tank sibling aliases#85
zer0stars merged 1 commit into
mainfrom
fix/latest-cloudevent-nullable-on-empty

Conversation

@zer0stars

Copy link
Copy Markdown
Member

Problem

latestCloudEvent (and latestIndex) were non-nullable (CloudEvent!), and the resolver returned a sql.ErrNoRows-wrapped error ("no cloud events found") for any source with no matching event. In an aliased multi-source query, GraphQL null-propagation from the errored non-null field bubbles up and nulls the entire data object — wiping every sibling alias that did resolve.

dimo-app-backend's getName batches per-source nickname lookups [caller, owner, dev-license] as aliases in one request. The dev-license source rarely has a per-vehicle nickname, so its alias always errored → the owner's real nickname was wiped → /v2/vehicles/:id/summary returned no name (e.g. token 22892 "Loux Transport").

Fix

  • Make latestCloudEvent and latestIndex nullable in the schema.
  • Resolvers return (nil, nil) on errors.Is(err, sql.ErrNoRows) — mirroring the existing cloudEvents/indexes list resolvers — so an empty source resolves to null without poisoning its siblings.
  • Regenerate gqlgen (marshaller flips marshalN*marshalO*).

Test

internal/graph/null_propagation_test.go: ClickHouse-backed aliased latestIndex query with one populated + one empty source. Verified red without the fix (fails with the exact no cloud events found signature), green with it.

A source with no matching event made the non-null latestCloudEvent field
error ("no cloud events found"), and GraphQL null-propagation bubbled the
null to the root `data` — tanking every sibling alias in an aliased
multi-source query. dimo-app-backend's getName batches per-source nickname
lookups this way, so a vehicle whose owner had a nickname but whose
dev-license source did not resolved to no name at all (e.g. token 22892
"Loux Transport").

Make latestCloudEvent and latestIndex nullable and return (nil, nil) on
sql.ErrNoRows (mirroring the cloudEvents/indexes list resolvers), so an
empty source resolves to null without poisoning its siblings. Regenerate
gqlgen. Add a ClickHouse-backed regression test over the aliased path.
@zer0stars zer0stars force-pushed the fix/latest-cloudevent-nullable-on-empty branch from 5d4c289 to 97918b3 Compare June 15, 2026 19:20
@zer0stars zer0stars merged commit f4680af into main Jun 15, 2026
4 checks passed
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.

1 participant