-
Notifications
You must be signed in to change notification settings - Fork 132
Fix nil pointer dereference in environment variable validation #2252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This fixes a panic that occurs when running MCP servers via GitHub Actions with environment variables when no secrets manager is configured. The code now gracefully handles the case where secretsManager is nil, allowing both Actions-based (env vars) and Docker-based (secrets manager) workflows to coexist. Fixes stacklok#1469
gofmt fixed a formatting issue with an extra blank line in the nil check code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a nil pointer dereference panic that occurs when running MCP servers with environment variables in environments where no secrets manager is configured (e.g., GitHub Actions).
Key Changes:
- Added nil check before accessing
secretsManager.GetSecret()
to prevent panic - Gracefully falls through to environment variable prompts when secrets manager is unavailable
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2252 +/- ##
==========================================
- Coverage 53.33% 53.31% -0.02%
==========================================
Files 231 231
Lines 29529 29536 +7
==========================================
- Hits 15749 15747 -2
- Misses 12647 12656 +9
Partials 1133 1133 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Add more context to explain why secrets manager might be null: - Setup incomplete - Missing provider This provides clearer guidance for users and developers.
Break long log message into multiple lines to match file formatting pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Description
Fixes a panic that occurs when running MCP servers with environment variables when no secrets manager is configured.
Related to #1469
The Problem
When running
thv run <server>
with environment variables in an environment without a configured secrets manager (e.g., GitHub Actions), the code panics with a nil pointer dereference atpkg/runner/env.go:117
.The Fix
Added a nil check before calling
secretsManager.GetSecret()
to gracefully handle the case where the secrets manager is not available.Impact
Before: Panic when running MCP servers without secrets manager
After: Graceful handling - falls through to environment variables or prompts
This maintains backward compatibility:
Testing