Fix nil returns from BaseDeps.Logger and BaseDeps.Metrics when Obsv is nil#2264
Merged
mattdholloway merged 4 commits intoadd-logging-stack-v2from Mar 26, 2026
Merged
Fix nil returns from BaseDeps.Logger and BaseDeps.Metrics when Obsv is nil#2264mattdholloway merged 4 commits intoadd-logging-stack-v2from
mattdholloway merged 4 commits intoadd-logging-stack-v2from
Conversation
13 tasks
… Obsv is nil Agent-Logs-Url: https://github.com/github/github-mcp-server/sessions/53221b0b-abb4-4138-a147-3ce9e13b379a Co-authored-by: mattdholloway <918573+mattdholloway@users.noreply.github.com>
…ewExporters Agent-Logs-Url: https://github.com/github/github-mcp-server/sessions/53221b0b-abb4-4138-a147-3ce9e13b379a Co-authored-by: mattdholloway <918573+mattdholloway@users.noreply.github.com>
Contributor
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Copilot
AI
changed the title
[WIP] [WIP] Address feedback on OSS logging adapter for http implementation
Fix nil returns from BaseDeps.Logger and BaseDeps.Metrics when Obsv is nil
Mar 26, 2026
Copilot stopped work on behalf of
mattdholloway due to an error
March 26, 2026 15:28
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns the HTTP server’s observability wiring and ToolDependencies defaults with the newer observability abstraction introduced in #2008, ensuring logger/metrics access is nil-safe across dependency injection paths.
Changes:
- Initialize HTTP server observability exporters with
metrics.NewNoopMetrics()instead ofnil. - Make
github.BaseDepsreturn a discard logger and no-op metrics whenObsvis unset (nil) to avoid nil returns fromToolDependencies.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/http/server.go | Uses a no-op metrics implementation when constructing observability.Exporters for the HTTP server. |
| pkg/github/dependencies.go | Ensures BaseDeps.Logger() / BaseDeps.Metrics() are nil-safe when Obsv is nil. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BaseDeps.Logger()andBaseDeps.Metrics()returnednilwhenObsvisnil, creating an inconsistent contract that invited nil-pointer panics at any call site. This PR ensures both methods always return safe, functional defaults.Why
ToolDependencies.Logger(ctx)andToolDependencies.Metrics(ctx)are expected to be callable without nil checks at call sites — returningnilviolated that contract. Many tests constructBaseDepsas partial struct literals without settingObsv, making this a practical risk.What changed
BaseDeps.Logger(): returnsslog.New(slog.DiscardHandler)instead ofnilwhenObsv == nilBaseDeps.Metrics(): returnsmetrics.NewNoopMetrics()instead ofnilwhenObsv == nilpkg/http/server.go: passesmetrics.NewNoopMetrics()explicitly toobservability.NewExporters()instead ofnil, ensuring the resultingExportershas a valid metrics implementation throughoutMCP impact
Prompts tested (tool changes only)
Security / limits
Tool renaming
Lint & tests
./script/lint./script/testDocs
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.