Commit 9269815
committed
fix(fn-runtime): meta client must use X-Meta-Schema, not X-Api-Name
The meta GraphQLClient created in createClients() is used for queries
against platform-level data (databases, sites, domains, themes — tables
in metaschema_public). It should NOT use tenant API routing.
Sending X-Api-Name: <name> causes the server to look up every schema
registered for that API in services_public.api_schemas. The 'private'
API in particular is registered (per metaschema_generators.provision_database_apis)
with both the *_public and *_private variants of every module schema.
graphile-build-pg then tries to introspect all of them, finds tables
that exist under the same name in two schemas (e.g. identity_providers
in both constructive_auth_public and constructive_auth_private), and
fails the schema build with:
Error: Attempted to add a second codec named 'identityProviders'
(existing: RecordCodec(identityProviders), new: RecordCodec(identityProviders))
After the schema build fails, every request to that server returns a
500 'Unknown error occurred', so functions calling GetDatabaseInfo via
the meta client get back nothing usable.
The correct routing for platform data is X-Meta-Schema: true, which
takes the schema list from API_META_SCHEMAS env var rather than
querying the DB. This matches the routing the older in-monorepo
implementation used (see constructive/functions/send-email-link/src/index.ts
on the constructive repo). The detail was lost during the extraction
into this repo.
Bug present since the initial setup commit (272763a, 2026-02-11) but
not exercised until consumers (e.g. constructive-hub) started loading
this fn-runtime instead of the in-monorepo function.1 parent c0ebc1c commit 9269815
1 file changed
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
64 | 69 | | |
65 | 70 | | |
66 | | - | |
67 | | - | |
68 | | - | |
| 71 | + | |
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
| |||
0 commit comments