{"record":{"id":"e36b4baf09cd8efc","repo":"vercel/next.js","slug":"unexpected-root-span-type-rootspanattributes-ge","errorCode":null,"errorMessage":"Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js","messagePattern":"Unexpected root span type '(.+?)'\\. Please report this Next\\.js issue https://github\\.com/vercel/next\\.js","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/base-server.ts","lineNumber":917,"sourceCode":"              if (res.statusCode && res.statusCode >= 500) {\n                // For 5xx status codes: SHOULD be set to 'Error' span status.\n                // x-ref: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status\n                span.setStatus({\n                  code: SpanStatusCode.ERROR,\n                })\n                // For span status 'Error', SHOULD set 'error.type' attribute.\n                span.setAttribute('error.type', res.statusCode.toString())\n              }\n\n              const rootSpanAttributes = tracer.getRootSpanAttributes()\n              // We were unable to get attributes, probably OTEL is not enabled\n              if (!rootSpanAttributes) return\n\n              if (\n                rootSpanAttributes.get('next.span_type') !==\n                BaseServerSpan.handleRequest\n              ) {\n                console.warn(\n                  `Unexpected root span type '${rootSpanAttributes.get(\n                    'next.span_type'\n                  )}'. Please report this Next.js issue https://github.com/vercel/next.js`\n                )\n                return\n              }\n\n              const route = rootSpanAttributes.get('next.route')\n              if (route) {\n                const name = isRSCRequest\n                  ? `RSC ${method} ${route}`\n                  : `${method} ${route}`\n\n                span.setAttributes({\n                  'next.route': route,\n                  'http.route': route,\n                  'next.span_name': name,\n                })","sourceCodeStart":899,"sourceCodeEnd":935,"githubUrl":"https://github.com/vercel/next.js/blob/258b1c1bc05f7099816b88f70b7b3422b24a4b8d/packages/next/src/server/base-server.ts#L899-L935","documentation":"Post-response telemetry sanity check in Server.handleRequest (base-server.ts): after finishing a request it reads the OTEL root span attributes via tracer.getRootSpanAttributes() and expects next.span_type to be BaseServerSpan.handleRequest. Any other value means tracing instrumentation wrapped the request wrongly (custom tracer setup or nested spans) — a Next.js-internal inconsistency, hence the request to report it.","triggerScenarios":"Thrown at packages/next/src/server/base-server.ts:910 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Report the issue at https://github.com/vercel/next.js with a reproduction; this indicates an internal tracing bug."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"258b1c1bc05f7099816b88f70b7b3422b24a4b8d","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}