Skip to content

fix(tests): save/restore HERMES_CRON_SESSION in approval test teardown - #36791

Closed
kyssta-exe wants to merge 2 commits into
NousResearch:mainfrom
kyssta-exe:fix/test-approval-cron-env-leak
Closed

fix(tests): save/restore HERMES_CRON_SESSION in approval test teardown#36791
kyssta-exe wants to merge 2 commits into
NousResearch:mainfrom
kyssta-exe:fix/test-approval-cron-env-leak

Conversation

@kyssta-exe

Copy link
Copy Markdown
Contributor

Problem

When HERMES_CRON_SESSION=1 leaks from the parent process (e.g. cron scheduler running before the test suite), two tests fail:

  1. TestApprovalTimeoutIsNotConsent::test_timeout_returns_approved_false_with_no_consent — takes the cron-path instead of gateway-path because _is_gateway_approval_context() checks CRON_SESSION before GATEWAY_SESSION
  2. TestResumeQuietStderr::test_session_not_found_goes_to_stdout_in_full_mode_cprint output routing depends on whether a cron context is active

Fix

Added HERMES_CRON_SESSION to the saved env vars in TestApprovalTimeoutIsNotConsent.setup_method(), and explicitly .pop() it to ensure a clean gateway test context.

Testing

  • tests/tools/test_approval.py::TestApprovalTimeoutIsNotConsent — 4/4 passing
  • tests/cli/test_resume_quiet_stderr.py — 4/4 passing

This is a test-infrastructure fix that prevents environment-dependent test failures in CI or local runs when cron jobs are active.

…recommendation

The
┌─────────────────────────────────────────────────────────┐
│          ⚕ Hermes — OpenClaw Migration                 │
└─────────────────────────────────────────────────────────┘

✗ OpenClaw directory not found: /root/.openclaw
  Make sure your OpenClaw installation is at the expected path.
  You can specify a custom path: hermes claw migrate --source /path/to/.openclaw command prints a recommendation to stop
the gateway with 'hermes stop', but that is not a valid top-level
command. The correct command is 'hermes gateway stop'.

Closes NousResearch#36771
When HERMES_CRON_SESSION=1 leaks from the parent process (e.g. cron
scheduler running before the test suite), the approval gateway test
setup doesn't unset it. The approval code's _is_gateway_approval_context()
checks CRON_SESSION before GATEWAY_SESSION, causing the timeout approval
test to take the cron-path instead of the gateway-path.

This leaked env var also affected the resume-quiet-stderr test, where
_cprint output routing depends on whether a cron context is active.

Fix: add HERMES_CRON_SESSION to the saved env vars in the approval test's
setup_method, and explicitly pop it so the test gateway context is clean.

Closes test failures:
  - TestApprovalTimeoutIsNotConsent::test_timeout_returns_approved_false_with_no_consent
  - TestResumeQuietStderr::test_session_not_found_goes_to_stdout_in_full_mode
@kyssta-exe kyssta-exe closed this Jun 1, 2026
@kyssta-exe
kyssta-exe deleted the fix/test-approval-cron-env-leak branch June 1, 2026 13:25
@alt-glitch alt-glitch added type/test Test coverage or test infrastructure comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have labels Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/test Test coverage or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants