{"record":{"id":"9063f36b7a80410e","repo":"temporalio/temporal","slug":"no-nexus-context-set-on-context","errorCode":null,"errorMessage":"no nexus context set on context","messagePattern":"no nexus context set on context","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/frontend/nexus_handler.go","lineNumber":371,"sourceCode":"\tauth                          *authorization.Interceptor\n\ttelemetryInterceptor          *interceptor.TelemetryInterceptor\n\trequestErrorHandler           *interceptor.RequestErrorHandler\n\tredirectionInterceptor        *interceptor.Redirection\n\tforwardingEnabledForNamespace dynamicconfig.BoolPropertyFnWithNamespaceFilter\n\tforwardingClients             *cluster.FrontendHTTPClientCache\n\tpayloadSizeLimit              dynamicconfig.IntPropertyFnWithNamespaceFilter\n\theadersBlacklist              dynamicconfig.TypedPropertyFn[*regexp.Regexp]\n\tuseForwardByEndpoint          dynamicconfig.BoolPropertyFn\n\tmetricTagConfig               dynamicconfig.TypedPropertyFn[chasmnexus.NexusMetricTagConfig]\n\thttpTraceProvider             commonnexus.HTTPClientTraceProvider\n}\n\n// Extracts a nexusContext from the given ctx and returns an operationContext with tagged metrics and logging.\n// Resolves the context's namespace name to a registered Namespace.\nfunc (h *nexusHandler) getOperationContext(ctx context.Context, method string) (*operationContext, error) {\n\tnc, ok := ctx.Value(nexusContextKey{}).(*nexusContext)\n\tif !ok {\n\t\treturn nil, errors.New(\"no nexus context set on context\")\n\t}\n\toc := operationContext{\n\t\tnexusContext:                  nc,\n\t\tmethod:                        method,\n\t\tclusterMetadata:               h.clusterMetadata,\n\t\tclientVersionChecker:          headers.NewDefaultVersionChecker(),\n\t\tauth:                          h.auth,\n\t\ttelemetryInterceptor:          h.telemetryInterceptor,\n\t\trequestErrorHandler:           h.requestErrorHandler,\n\t\tredirectionInterceptor:        h.redirectionInterceptor,\n\t\tforwardingEnabledForNamespace: h.forwardingEnabledForNamespace,\n\t\theadersBlacklist:              h.headersBlacklist,\n\t\tmetricTagConfig:               h.metricTagConfig,\n\t\tcleanupFunctions:              make([]func(map[string]string, error), 0),\n\t}\n\toc.metricsHandlerForInterceptors = h.metricsHandler.WithTags(\n\t\tmetrics.OperationTag(method),\n\t\tmetrics.NamespaceTag(nc.namespaceName),","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/frontend/nexus_handler.go#L353-L389","documentation":"Raised by getOperationContext when the request context does not carry a nexusContext value, meaning the Nexus operation handler was invoked outside the framework that injects Nexus request metadata (namespace, endpoint, header info). StartOperation/CancelOperation depend on this context to resolve the namespace and set up metrics/logging.","triggerScenarios":"Calling StartOperation or CancelOperation (or code paths that call getOperationContext) with a plain context.Context instead of the request context delivered by the Nexus framework through the handler.","commonSituations":"Tests invoking handler methods directly with context.Background(), custom handler wrappers that strip the context, or calling handler internals from unrelated RPC paths.","solutions":["Invoke the Nexus handler through the nexus framework request path so the framework-injected context is passed through","In tests, build the context with the nexusContextKey value (or use the handler's provided test helpers) before calling StartOperation/CancelOperation","Audit any middleware/wrapping code to ensure it propagates ctx unchanged rather than replacing it"],"exampleFix":"// before\nctx := context.Background()\nh.StartOperation(ctx, req)\n// after\nctx = context.WithValue(ctx, nexusContextKey{}, nc)\nh.StartOperation(ctx, req)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func nexusContextFromCtx(ctx context.Context) (*nexusContext, bool) {\n  nc, ok := ctx.Value(nexusContextKey{}).(*nexusContext)\n  return nc, ok\n}","tryCatchPattern":null,"preventionTips":["Only invoke Nexus handler methods with the framework-provided request context","Avoid context replacement in middleware; wrap values instead","In tests, inject the nexus context explicitly before calling handler methods"],"tags":["nexus","context","handler","temporal-server"],"backgroundTag":"missing-context-value","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}