Fix: Only reference Safe Inputs env vars when Safe Inputs is enabled #9835
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.