fix(codex-runtime): prevent HERMES_HOME tempdir leakage into config.toml (Bug #26250-C) - #26258
Closed
liuhao1024 wants to merge 1 commit into
Closed
Conversation
…oml (Bug NousResearch#26250-C) Derive HERMES_HOME canonically from get_hermes_home() rather than reading os.environ at migrate-time. This prevents pytest tempdir leakage into user's real ~/.codex/config.toml. Sanity checks: - Path must exist (hermes_path.exists()) - Path must not be a pytest tempdir ("pytest-of-" not in hermes_home) Add regression tests: - test_pytest_tempdir_blocked: HERMES_HOME from pytest tempdir should NOT be written - test_nonexistent_hermes_home_blocked: HERMES_HOME for nonexistent path should NOT be written
Collaborator
Contributor
|
Closing as superseded by #26260. Triage notes (high confidence): Thanks for the contribution — the underlying problem this PR addresses has been resolved by the linked PR on current main. If you believe this was closed in error, please comment and we'll reopen. (Bulk-closed during a CLI PR triage sweep.) |
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.
Fixes hermes codex-runtime migrate produces invalid ~/.codex/config.toml (HERMES_HOME tempdir leakage) #26250-C
Summary
Prevent
HERMES_HOMEfromos.environleaking into user's real~/.codex/config.tomlwhenhermes codex-runtime migrateruns in a pytest environment. Pytest tempdirs (e.g.,pytest-of-*) should NOT be written to the generated config file.Root Cause
_build_hermes_tools_mcp_entry()readHERMES_HOMEdirectly fromos.environ.get("HERMES_HOME")without any sanity checks. When pytest monkeypatch setsHERMES_HOMEto a tempdir, that path gets burned into the user's real config file, causing codex MCP subprocess to fail silently.Fix
HERMES_HOMEcanonically fromget_hermes_home()instead of readingos.environat migrate-timehermes_path.exists())"pytest-of-" not in hermes_home)If both checks fail, omit
HERMES_HOMEfrom the generated config entirely. Codex's spawned subprocess will resolve its ownHERMES_HOMEon startup, so passthrough is optional.Regression Coverage
Added
TestHERMESHomeSanityclass with two tests:test_pytest_tempdir_blocked: Verifies thatHERMES_HOMEpointing at a pytest tempdir is NOT written to config.tomltest_nonexistent_hermes_home_blocked: Verifies thatHERMES_HOMEpointing at a nonexistent path is NOT written to config.tomlBoth tests verify migration succeeds but the invalid HERMES_HOME value is not present in the output.
Test Plan
python -m pytest tests/hermes_cli/test_codex_runtime_plugin_migration.py::TestHERMESHomeSanity -vpython -m pytest tests/hermes_cli/test_codex_runtime_plugin_migration.py -x(full test file)Risk Assessment
Low — change is scoped to
hermes_tools_mcp_entry()env passthrough logic. MCP server migration and permissions rendering use the same paths as before. Migration behavior only changes when HERMES_HOME would have been written; codex subprocesses resolve their own HERMES_HOME anyway.