{"record":{"id":"4b07749eef0170e7","repo":"dgraph-io/dgraph","slug":"internal-server-error-a-panic-was-trapped-this","errorCode":null,"errorMessage":"Internal Server Error - a panic was trapped.  This indicates a bug in the GraphQL server.  A stack trace was logged.  Please let us know by filing an issue with the stack trace.","messagePattern":"Internal Server Error - a panic was trapped\\.  This indicates a bug in the GraphQL server\\.  A stack trace was logged\\.  Please let us know by filing an issue with the stack trace\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"graphql/api/panics.go","lineNumber":25,"sourceCode":"\nimport (\n\t\"runtime/debug\"\n\n\t\"github.com/golang/glog\"\n\t\"github.com/pkg/errors\"\n)\n\n// PanicHandler catches panics to make sure that we recover from panics during\n// GraphQL request execution and return an appropriate error.\n//\n// If PanicHandler recovers from a panic, it logs a stack trace, creates an error\n// and applies fn to the error.\nfunc PanicHandler(fn func(error), query string) {\n\tif err := recover(); err != nil {\n\t\t// Log the panic along with query which caused it.\n\t\tglog.Errorf(\"panic: %s.\\n query: %s\\n trace: %s\", err, query, string(debug.Stack()))\n\n\t\tfn(errors.Errorf(\"Internal Server Error - a panic was trapped.  \" +\n\t\t\t\"This indicates a bug in the GraphQL server.  A stack trace was logged.  \" +\n\t\t\t\"Please let us know by filing an issue with the stack trace.\"))\n\t}\n}\n","sourceCodeStart":7,"sourceCodeEnd":30,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/api/panics.go#L7-L30","documentation":"This is Dgraph's GraphQL panic-recovery message. The `PanicHandler` wrapper runs `recover()` around GraphQL resolution; when the server code panics, it logs the panic with a stack trace via glog and replaces the real error with this generic internal-server-error string so internals never leak to clients.","triggerScenarios":"Any GraphQL resolver that panics — nil pointer dereference, index out of range, type assertion failure — during query/mutation execution. The panic is caught in PanicHandler (called from the Resolve path), the stack trace is written to the server log, and the client gets this message.","commonSituations":"Malformed or deeply nested queries that hit edge cases in resolver code; bugs in custom lambda resolvers; schema/data conditions the server didn't anticipate; concurrent requests racing on shared state.","solutions":["Check the Dgraph server logs for the `panic:` entry with the stack trace — it names the real failing function and reason","File an issue at github.com/dgraph-io/dgraph with the stack trace and the query that triggered it, as the message instructs","Reproduce with the logged query to identify the input (variable values, schema feature) that triggers the panic","Upgrade to the latest Dgraph release, since panics are usually fixed as bugs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const res = await fetch('/admin/graphql', {method:'POST', body: JSON.stringify({query})});\n  const body = await res.json();\n  if (body.errors?.some(e => e.message.includes('panic was trapped'))) {\n    console.error('Server bug; check Dgraph server logs for stack trace and file an issue');\n  }\n} catch (err) { /* network failure path */ }","preventionTips":["Keep Dgraph upgraded to the latest patch release","Include the failing query and stack trace from server logs when reporting","Avoid exotic schema edge cases until a fix is released"],"tags":["graphql","panic","internal-server-error"],"backgroundTag":"graphql-server-panic","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}