Prevent Codex MCP gateway startup failures from config.toml self-copy#27582
Prevent Codex MCP gateway startup failures from config.toml self-copy#27582
Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c4a194bc-0a8d-4011-b5e0-210d087dc6ef Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c4a194bc-0a8d-4011-b5e0-210d087dc6ef Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot recompile |
There was a problem hiding this comment.
Pull request overview
Prevents Codex MCP gateway startup from failing when the generated MCP config sync script attempts to cp a file onto itself (same source/destination path).
Changes:
- Add a conditional guard around copying
/tmp/gh-aw/mcp-config/config.tomlinto${CODEX_HOME}/config.tomlduring Codex MCP config sync. - Update the Codex MCP config rendering test expectations to match the newly generated script line.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/codex_mcp.go | Updates generated shell script to skip cp when source/destination paths match. |
| pkg/workflow/codex_engine_test.go | Adjusts expected rendered script lines for MCP config generation. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
| yaml.WriteString(" chmod 600 \"/tmp/gh-aw/mcp-config/config.toml\"\n") | ||
| yaml.WriteString(" mkdir -p \"${CODEX_HOME}\"\n") | ||
| yaml.WriteString(" cp \"/tmp/gh-aw/mcp-config/config.toml\" \"${CODEX_HOME}/config.toml\"\n") | ||
| yaml.WriteString(" if [ \"/tmp/gh-aw/mcp-config/config.toml\" != \"${CODEX_HOME}/config.toml\" ]; then cp \"/tmp/gh-aw/mcp-config/config.toml\" \"${CODEX_HOME}/config.toml\"; fi\n") |
There was a problem hiding this comment.
The self-copy guard compares path strings, which won’t catch cases where ${CODEX_HOME} resolves to the same file via a trailing slash (/tmp/.../mcp-config/), .., or a symlink; cp will still treat the files as identical and exit non-zero. Consider using a filesystem identity check (e.g., test ... -ef ... / [ ... -ef ... ] with a negation) instead of string inequality, and emit the if/then/cp/fi as a multi-line block like other generated run scripts for readability/consistency (see pkg/workflow/compiler_yaml_ai_execution.go:161-164).
| yaml.WriteString(" if [ \"/tmp/gh-aw/mcp-config/config.toml\" != \"${CODEX_HOME}/config.toml\" ]; then cp \"/tmp/gh-aw/mcp-config/config.toml\" \"${CODEX_HOME}/config.toml\"; fi\n") | |
| yaml.WriteString(" if ! [ \"/tmp/gh-aw/mcp-config/config.toml\" -ef \"${CODEX_HOME}/config.toml\" ]; then\n") | |
| yaml.WriteString(" cp \"/tmp/gh-aw/mcp-config/config.toml\" \"${CODEX_HOME}/config.toml\"\n") | |
| yaml.WriteString(" fi\n") |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/60acaed8-64e0-4a0a-8422-51565ff940d0 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
🧪 Test Quality Sentinel ReportTest Quality Score: 100/100✅ Excellent test quality
Test Classification Details
AnalysisThis PR makes a single targeted change: the The corresponding test update in
What invariant does this test enforce? When Language SupportTests analyzed:
Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators. References: §24729659653
|
There was a problem hiding this comment.
✅ Test Quality Sentinel: 100/100. Test quality is acceptable — 0% of new/modified tests are implementation tests (threshold: 30%). The single modified test (TestCodexEngineRenderMCPConfig) is a well-structured behavioral contract test that correctly captures the self-copy guard introduced by this fix.
Recent Codex workflows using MCP CLI servers (
serena,mempalace) were failing in Start MCP Gateway despite successful gateway health and MCP connectivity checks. The step was aborting on a same-filecpoperation when syncing Codex MCP config.Root cause
/tmp/gh-aw/mcp-config/config.toml${CODEX_HOME}/config.tomlCODEX_HOME=/tmp/gh-aw/mcp-config, socpattempted a self-copy and exited non-zero.Compiler change (runtime script generation)
pkg/workflow/codex_mcp.goTest updates
pkg/workflow/codex_engine_test.go