Skip to content

fix(cli): prevent CLAUDE_CODE_ENTRYPOINT leak into local spawn#452

Merged
hqhq1025 merged 1 commit intotiann:mainfrom
hqhq1025:fix/local-spawn-entrypoint-leak
Apr 14, 2026
Merged

fix(cli): prevent CLAUDE_CODE_ENTRYPOINT leak into local spawn#452
hqhq1025 merged 1 commit intotiann:mainfrom
hqhq1025:fix/local-spawn-entrypoint-leak

Conversation

@hqhq1025
Copy link
Copy Markdown
Collaborator

Summary

  • Local-mode sessions started via hapi are invisible to claude --resume because the child process inherits CLAUDE_CODE_ENTRYPOINT=sdk-ts from the parent
  • extractSDKMetadataAsync()query() sets this env var on the current process for SDK metadata extraction; claudeLocal() then spreads process.env into the child, leaking it
  • Fix: destructure out CLAUDE_CODE_ENTRYPOINT before building the child env so the local spawn uses its own default entrypoint

Test plan

  • Start a session via hapi locally (terminal mode)
  • Send at least one message and get a response
  • Exit the session
  • Run claude --resume — the session should now appear in the list

Closes #450

extractSDKMetadataAsync() calls query() which sets
CLAUDE_CODE_ENTRYPOINT='sdk-ts' on the current process env.
When claudeLocal() later spawns the claude CLI, the child
inherits this env var, causing Claude Code to treat the
session as SDK-launched. This makes the session invisible
to `claude --resume`.

Strip CLAUDE_CODE_ENTRYPOINT from the child env so the
local spawn uses its own default entrypoint.

Closes tiann#450
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • None.

Summary
Review mode: initial
No diff-scoped correctness, security, or regression issues found in the added/modified lines.
Residual risk/testing gap: the fix in cli/src/claude/claudeLocal.ts:85 is only covered by the manual PR test plan; I did not find an automated regression test that asserts CLAUDE_CODE_ENTRYPOINT is stripped before the local Claude spawn.

Testing
Not run (automation)

HAPI Bot

@hqhq1025 hqhq1025 merged commit 74377fa into tiann:main Apr 14, 2026
2 checks passed
Hwwwww-dev pushed a commit to Hwwwww-dev/hapi that referenced this pull request Apr 17, 2026
…#452)

extractSDKMetadataAsync() calls query() which sets
CLAUDE_CODE_ENTRYPOINT='sdk-ts' on the current process env.
When claudeLocal() later spawns the claude CLI, the child
inherits this env var, causing Claude Code to treat the
session as SDK-launched. This makes the session invisible
to `claude --resume`.

Strip CLAUDE_CODE_ENTRYPOINT from the child env so the
local spawn uses its own default entrypoint.

Closes tiann#450
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can not resume session when using hapi to run it locally

1 participant