hasura/graphql-engine · error · Error
Cannot find database ${config.db}
Error message
Cannot find database ${config.db} What it means
This error is thrown by the /query route of the Hasura Data Connector reference agent when the database named in the request config cannot be found in the server's loaded static data. The config comes from the X-Hasura-DataConnector-Config header, and config.db is resolved (prefixed with getDbStoreName) to a key in the staticData map populated at startup via loadStaticData. If no matching entry exists, the request is rejected before any query runs.
Source
Thrown at dc-agents/reference/src/index.ts:92
return getSchema(staticData, config, request.body);
},
);
server.post<{ Body: QueryRequest; Reply: QueryResponse }>(
'/query',
async (request, _response) => {
server.log.info(
{ headers: request.headers, query: request.body },
'query.request',
);
const config = getConfig(request);
const dbStoreName = config.db
? getDbStoreName(config.db)
: defaultDbStoreName;
if (!(dbStoreName in staticData))
throw new Error(`Cannot find database ${config.db}`);
const data = filterAvailableTables(staticData[dbStoreName], config);
return queryData(getTable(data, config), request.body);
},
);
// Methods on dataset resources.
//
// Examples:
//
// > curl -H 'content-type: application/json' -XGET localhost:8100/datasets/templates/Chinook
// {"exists": true}
//
server.get<{ Params: { name: string }; Reply: DatasetGetTemplateResponse }>(
'/datasets/templates/:name',
async (request, _response) => {
server.log.info(
{ headers: request.headers, query: request.body },View on GitHub (pinned to 724551b9ae)
Solutions
- Check the value of the X-Hasura-DataConnector-Config header's db field and confirm it matches an entry the server loaded (inspect server startup logs / loadStaticData output).
- For clones, create the dataset first via POST /datasets/clones/{name} with {"from":"<template>"}; the config then uses the returned db value (e.g. "$foo").
- List available templates via GET /datasets/templates/{name} to verify the database name exists.
- If the server loaded nothing, restart the agent ensuring the static data directory/DB environment is correctly configured so loadStaticData populates staticData.
Example fix
// before
await fetch('http://localhost:8100/query', {
headers: { 'X-Hasura-DataConnector-Config': JSON.stringify({ db: 'foo' }) },
method: 'POST',
body: JSON.stringify(query),
});
// after: create the clone first, then use its returned config
const clone = await fetch('http://localhost:8100/datasets/clones/foo', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ from: 'Chinook' }),
}).then(r => r.json());
// clone.config.db === '$foo'
await fetch('http://localhost:8100/query', {
headers: { 'X-Hasura-DataConnector-Config': JSON.stringify(clone.config) },
method: 'POST',
body: JSON.stringify(query),
}); Defensive patterns
Strategy: validation
Validate before calling
const config = JSON.parse(headerValue);
const dbStoreName = config.db ? `$${config.db.replace(/^\$/, '')}` : undefined;
const exists = await fetch(`http://localhost:8100/datasets/templates/${name}`).then(r => r.json());
if (!exists) throw new Error('dataset not available'); Type guard
const isValidDbConfig = (c: unknown): c is { db: string } =>
typeof c === 'object' && c !== null && typeof (c as any).db === 'string'; Try / catch
try { await queryAgent(config, query); } catch (e) { if (e instanceof Error && e.message.startsWith('Cannot find database')) { /* recreate clone or fix config header */ } throw e; } Prevention
- Verify dataset existence via GET /datasets/templates/:name before querying
- Create clones through POST /datasets/clones/:name and reuse the returned config verbatim
- Log the X-Hasura-DataConnector-Config header value when debugging connector requests
When it happens
Trigger: Sending a POST /query with a config header whose db field names a dataset that was never loaded — e.g. {"db":"foo"} when staticData only contains the default store or "$foo"-prefixed clones created via /datasets/clones. Also occurs if the server was started with different templates/clone directories than the client expects, or if db is misspelled.
Common situations: Config header mismatch between Hasura DDN and the connector agent; querying a clone before it is created (clone names are stored with a '$' prefix via getDbStoreName); running the agent against a different working directory so static data loads nothing; typos in the db config value.
Related errors
- error in creation of new migrate instance %w
- makePerformExistsSubquery: only table relationships currentl
- Unexpected type of results.aggregates.count (${count}) expec
- Unexpected number of rows (${rows.length}) returned by order
- Column order by target path did not end in a column field va
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/f752cdbdfabae6fb.
Report an issue: GitHub.