{"record":{"id":"d0fbf59781facdee","repo":"hasura/graphql-engine","slug":"sqlite-agent-uncaught-exception","errorCode":null,"errorMessage":"SQLite Agent: Uncaught Exception","messagePattern":"SQLite Agent: Uncaught Exception","errorType":"http","errorClass":"ErrorResponse","httpStatus":500,"severity":"error","filePath":"dc-agents/sqlite/src/index.ts","lineNumber":96,"sourceCode":"  this.log.error(error);\n\n  if (isErrorWithStatusCode(error)) {\n    const errorResponse: ErrorResponse = {\n      type: error.type,\n      message: error.message,\n      details: error.details,\n    };\n    reply.status(error.code).send(errorResponse);\n  } else {\n    const errorResponse: ErrorResponse = {\n      type: 'uncaught-error',\n      message: 'SQLite Agent: Uncaught Exception',\n      details: {\n        name: (error as Error).name,\n        message: (error as Error).message,\n      },\n    };\n    reply.status(500).send(errorResponse);\n  }\n});\n\nif (METRICS) {\n  // See: https://www.npmjs.com/package/fastify-metrics\n  server.register(metrics, {\n    endpoint: '/metrics',\n    routeMetrics: {\n      enabled: true,\n      registeredRoutesOnly: false,\n    },\n  });\n}\n\nif (PERMISSIVE_CORS) {\n  // See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin\n  server.register(FastifyCors, {\n    origin: true,","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/dc-agents/sqlite/src/index.ts#L78-L114","documentation":"This is the SQLite Agent's top-level Fastify error handler: any uncaught exception thrown while handling an HTTP request in the agent results in this generic 500 response containing the underlying error's name and message. It is not a specific error itself but a catch-all that surfaces the root cause of request-processing failures (query building, schema parsing, SQLite execution, etc.).","triggerScenarios":"Any GET/POST route handler (query, explain, schema endpoints) throwing a non-ErrorWithStatusCode exception, e.g. a bug in query generation, sqlite-parser returning an unexpected AST shape, or a broken DB connection during request handling.","commonSituations":"Deploying the SQLite agent against a database whose DDL the parser cannot handle; sending malformed request bodies that bypass validation; runtime bugs in query.ts/schema.ts that throw plain Error objects instead of ErrorWithStatusCode.","solutions":["Read the `details.name` and `details.message` fields in the 500 response — they carry the original exception and pinpoint the real failure","Reproduce the failing request body locally against the agent with logging enabled to get a stack trace","If the root cause is an unsupported query feature (e.g. UDF targets), fix the client request; if it's a parser/DDL issue, simplify or fix the schema","File an issue with the request payload and stack trace if it's an internal bug in the agent"],"exampleFix":"// before: sending a target of type 'function'\nawait agent.query({ target: { type: 'function', name: 'my_udf' }, ... });\n// after: only query tables or interpolated targets\nawait agent.query({ target: { type: 'table', name: ['album'] }, ... });","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"// Wrap agent calls; inspect the generic 500 for root cause\ntry {\n  const res = await fetch(`${agentUrl}/query`, {...});\n  if (!res.ok) {\n    const err = await res.json();\n    // err.details.name / err.details.message hold the original exception\n    log.error({ cause: err.details }, 'sqlite agent failure');\n    throw new Error(err.details?.message ?? 'agent error');\n  }\n} catch (e) { /* surface to caller with context */ }","preventionTips":["Log `details.name`/`details.message` from every 500 — they carry the real error","Run the agent with verbose logging during development","Validate request bodies against the agent's schema before sending"],"tags":["sqlite","fastify","typescript","uncaught-exception","http-500"],"backgroundTag":"unhandled-server-exception","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}