{"record":{"id":"cd099037d85e1073","repo":"googleapis/mcp-toolbox","slug":"unable-to-get-logger-from-ctx-s-cd0990","errorCode":null,"errorMessage":"unable to get logger from ctx: %s","messagePattern":"unable to get logger from ctx: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/falkordb/falkordb.go","lineNumber":87,"sourceCode":"\n// validateTLS rejects a TLS configuration whose settings contradict each\n// other. Without TLS there is no certificate to verify, so insecureSkipVerify\n// would otherwise be accepted and silently ignored.\nfunc (r Config) validateTLS() error {\n\tif !r.TLS.Enabled && r.TLS.InsecureSkipVerify {\n\t\treturn fmt.Errorf(\"tls.insecureSkipVerify is set on source %q but tls.enabled is false; enable TLS or remove the setting\", r.Name)\n\t}\n\treturn nil\n}\n\nfunc (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {\n\tif err := r.validateTLS(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tlogger, err := util.LoggerFromContext(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get logger from ctx: %s\", err)\n\t}\n\tif r.TLS.InsecureSkipVerify {\n\t\tlogger.WarnContext(ctx, fmt.Sprintf(\"TLS certificate verification is skipped (insecureSkipVerify: true) for FalkorDB source %s. This exposes traffic for this source to man-in-the-middle attacks. Do not use in production.\", r.Name))\n\t}\n\n\tclient, err := initFalkorDBClient(ctx, tracer, r)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create client: %w\", err)\n\t}\n\n\tif err := client.Conn.Ping(ctx).Err(); err != nil {\n\t\tclient.Conn.Close()\n\t\treturn nil, fmt.Errorf(\"unable to connect successfully: %w\", err)\n\t}\n\n\ts := &Source{\n\t\tConfig: r,\n\t\tClient: client,","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/falkordb/falkordb.go#L69-L105","documentation":"Initialize calls util.LoggerFromContext(ctx) to fetch the structured logger carried in the request context; if the context has no logger, initialization aborts with this error. It indicates the toolbox was invoked without the logger-injection middleware or with a bare context.","triggerScenarios":"Calling Initialize programmatically with a context.Context that never had a logger attached (e.g. custom embedding code, tests, or a modified main.go that skips the standard server setup).","commonSituations":"Custom Go embedders of mcp-toolbox constructing sources directly without using the toolbox server's context setup; unit tests passing context.Background().","solutions":["Use the standard toolbox server startup path, which injects the logger into the context","In custom code, attach a logger: `ctx = util.WithLogger(ctx, logger)` before calling Initialize","For tests, build a context with a logger helper from internal/util"],"exampleFix":"// before\nsrc, err := cfg.Initialize(context.Background(), tracer)\n// after\nctx := util.WithLogger(context.Background(), slog.Default())\nsrc, err := cfg.Initialize(ctx, tracer)","handlingStrategy":"validation","validationCode":"// Go: ensure the logger is in the context before Initialize\nif _, err := util.LoggerFromContext(ctx); err != nil {\n    ctx = util.WithLogger(ctx, slog.Default())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the standard toolbox server startup, which injects the logger","In custom embedders/tests, always call util.WithLogger on the context","Never pass bare context.Background() to source Initialize"],"tags":["context","logging","falkordb","initialization"],"backgroundTag":"missing-context-value","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}