{"record":{"id":"934cf592ae7d9e87","repo":"hasura/graphql-engine","slug":"user-defined-functions-not-supported-in-queries","errorCode":null,"errorMessage":"User defined functions not supported in queries","messagePattern":"User defined functions not supported in queries","errorType":"exception","errorClass":"ErrorWithStatusCode","httpStatus":500,"severity":"error","filePath":"dc-agents/sqlite/src/index.ts","lineNumber":204,"sourceCode":"  },\n);\n\n/**\n * @throws ErrorWithStatusCode\n */\nserver.post<{ Body: QueryRequest; Reply: QueryResponse }>(\n  '/query',\n  async (request, response) => {\n    server.log.info(\n      { headers: request.headers, query: request.body },\n      'query.request',\n    );\n    const end = queryHistogram.startTimer();\n    const config = getConfig(request);\n    const body = request.body;\n    switch (body.target.type) {\n      case 'function':\n        throw new ErrorWithStatusCode(\n          'User defined functions not supported in queries',\n          500,\n          { function: { name: body.target.name } },\n        );\n      case 'interpolated': // interpolated should actually work identically to tables when using the CTE pattern\n      case 'table':\n        try {\n          const result: QueryResponse = await queryData(\n            config,\n            sqlLogger,\n            body,\n          );\n          return result;\n        } finally {\n          end();\n        }\n    }\n  },","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/dc-agents/sqlite/src/index.ts#L186-L222","documentation":"The SQLite agent's query endpoint explicitly rejects requests whose `target.type` is `'function'`. User-defined functions are not supported as query targets because SQLite cannot treat a UDF call as a FROM-clause source the way the agent's CTE-based query generation requires. The agent returns HTTP 500 with details naming the rejected function.","triggerScenarios":"POSTing to the query route with a body where `target: { type: 'function', name: ... }`, e.g. when a client or Hasura connector forwards a command/UDF-style target to the SQLite agent.","commonSituations":"Reusing a connector client built for a database that supports table functions (e.g. BigQuery, Postgres UDFs) against SQLite; metadata that models a tracked function and routes queries to it; version changes in the query API where function targets were previously silently ignored.","solutions":["Change the request target to a real table (`type: 'table'`) or an interpolated target (`type: 'interpolated'`)","If you need computed data, materialize it into a table or use an interpolated query with a CTE","Remove tracked-function entries from metadata that point at the SQLite agent"],"exampleFix":"// before\n{ target: { type: 'function', name: 'top_albums', args: {...} } }\n// after\n{ target: { type: 'table', name: ['top_albums'] } }","handlingStrategy":"type-guard","validationCode":"if (body.target.type === 'function') throw new Error('UDF targets unsupported by SQLite agent');","typeGuard":"const isSupportedTarget = (t: any): t is {type:'table'|'interpolated'} => t.type === 'table' || t.type === 'interpolated';","tryCatchPattern":"null","preventionTips":["Keep connector clients engine-specific — don't reuse UDF-capable clients against SQLite","Add client-side schema validation of request targets"],"tags":["sqlite","query","udf","unsupported-feature","http-500"],"backgroundTag":"unsupported-query-target","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}