Fix: Only reference Safe Inputs env vars when Safe Inputs is enabled#9835
Merged
Fix: Only reference Safe Inputs env vars when Safe Inputs is enabled#9835
Conversation
- Modified collectMCPEnvironmentVariables to use IsSafeInputsEnabled instead of checking mcpTools list - Modified MCP gateway Docker command to conditionally include Safe Inputs env vars - Added comprehensive test coverage for conditional Safe Inputs env vars - Tests verify env vars are excluded when Safe Inputs not configured - Tests verify env vars are included when Safe Inputs is configured Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
All changes complete and tested: - Modified collectMCPEnvironmentVariables to use IsSafeInputsEnabled - Modified Docker command generation to conditionally add env vars - Created comprehensive test coverage - Ran recompile successfully - All validation passed Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix MCP gateway step to validate Safe Inputs environment variables
Fix: Only reference Safe Inputs env vars when Safe Inputs is enabled
Jan 13, 2026
8 tasks
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.
The MCP gateway step was unconditionally referencing
GH_AW_SAFE_INPUTS_PORTandGH_AW_SAFE_INPUTS_API_KEYenvironment variables, even when Safe Inputs was not configured. This caused the compiled workflow to reference step outputs that don't exist.Changes
collectMCPEnvironmentVariables: Replace manualmcpToolslist check withIsSafeInputsEnabled()to verify Safe Inputs is actually configured with toolsBefore/After
Before - workflow without Safe Inputs:
After - workflow without Safe Inputs:
docker run ... -e GITHUB_TOKEN ... # Safe Inputs env vars omittedWorkflows with Safe Inputs configured continue to include the variables as expected.
Test Coverage
Added
TestMCPGatewaySafeInputsEnvVarsConditionalwith cases for Copilot, Claude, and Codex engines, verifying env vars are present only when Safe Inputs is configured.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.