ADR-0079 — An empty catalogue is empty, not absent
- Status: Accepted
- Date: 2026-08-28
- Deciders: Track 005 phase 00
- Follows: ADR-0010 (the language switcher stays unmounted until strings are extracted), ADR-0078 (the catalogue serves what a registry vouches for)
Context
GET /api/v1/languages is the only path a stored catalogue has to a client, and
it carried none. LanguageRepository.ListActive selected a literal '{}' in
the strings position while the three admin reads beside it selected the
column, so an operator could write a translation, read it back on the admin
surface, and no client could ever receive it. apps/web's i18next bootstrap
awaits that response before first paint and built its resource bundles from the
literal.
Nothing noticed, for two reasons that compound. There are zero t() call sites
(ADR-0010), so an empty bundle renders exactly like a correct one. And
Language.Strings carried json:"strings,omitempty", so "the catalogue is
empty" and "there is no catalogue field" were the same wire bytes — the defect
had no shape a reader could see.
This is 005's first phase because every later phase reads through this endpoint: extraction has nowhere to deliver to until the read works.
Decision
The read selects the column. One word, and it is the whole defect; the rest of this decision is about the shape of what it now delivers.
An empty catalogue serialises as {}. omitempty comes off
Language.Strings, and Language.ForCatalogue normalises a nil catalogue to an
empty map on the way out. A language with nothing translated yet is a fact a
client can read and act on. A language whose strings field is missing is
indistinguishable from a server that served no catalogue at all — which is what
this endpoint did, invisibly, for as long as it existed. Only the empty case is
touched: what a key translates to is the admin's text, carried by reference,
never rebuilt or coerced.
Every active language's catalogue, in one response. Not the active one's by code, and no new route. The endpoint's one consumer builds a resource bundle per code from a single call, and a per-code route would serve a shape nobody reads — the defect this track exists to close, not a head start on phase 04. If phase 04 finds the payload gates first paint too heavily, that is the decision to revisit, with a measurement behind it.
The projection is a copy. ForCatalogue returns a copy for the reason
Plan.ForCatalogue does (ADR-0078): the handler holds a repository-owned
pointer, and normalising in place would normalise it for whatever else holds
that language.
Alternatives
Serve the projection narrowed to what the client reads — code, name,
direction, is_default, strings — dropping the row id, the operator's
ordering and flag, is_active and both timestamps from an anonymous
response. Tempting, and it is the direction ADR-0078 took for plans.settings.
It is refused here for the reason that same ADR refused it for translations,
taxes, status and order: those were declared columns on a declared type,
not an undeclared blob, and narrowing a described shape in place is a breaking
change that belongs under /api/v2/ if it is wanted at all. The over-serving is
recorded as an open item instead; it is the same question, and it is not this
phase's.
Normalise inside JSONMap.MarshalJSON. One place, every consumer. But
JSONMap is the repo's general JSONB carrier, and nil means real things
elsewhere — an absent capability key denies, an absent quota key unlimits
(ADR-0078). A type-wide null → {} would answer a question those callers
answer for themselves.
Leave omitempty and let the client's ?? {} cover it. The client already
does this, so nothing would look different — which is the point. "The consumer
compensates" is not a statement about what the server serves, and the
compensation is what kept the defect invisible.
Consequences
strings is now always present on every language payload, admin reads included:
a language whose column is SQL NULL serialises as "strings": null there,
where it was previously absent. Both are falsy to the one consumer that reads
it, and the public read never emits null.
The public response still carries the whole Language row. Anyone reading this
endpoint and expecting the narrowing ADR-0078 applied to plans will not find it;
the difference is declared columns versus an open blob, and it is deliberate.
The repository read is now pinned by an integration test rather than a mock — the defect was in the SQL, where the 96 green mock tests of the 2026-08-01 R2 audit could not see it.
Source: docs/decisions/0079-an-empty-catalogue-is-empty-not-absent.md