orca icon indicating copy to clipboard operation
orca copied to clipboard

Windows: grok-hook.cmd syntax error when GROK_HOME is empty (SessionStart fails)

Open Beyfish opened this issue 4 months ago • 3 comments

Summary

Beyfish avatar Jul 22 '26 13:07 Beyfish

I'd like to take this.

Root cause (code-level): grok-hook.cmd always runs:

set "ORCA_GROK_HOME=%GROK_HOME%"
if not "%GROK_HOME:~4096,1%"=="" set "ORCA_GROK_HOME="
if "%ORCA_GROK_HOME:~-1%"=="\" set "ORCA_GROK_HOME=%ORCA_GROK_HOME%."

When GROK_HOME is undefined/empty (common default), cmd still expands %GROK_HOME:~4096,1% / %ORCA_GROK_HOME:~-1% substring forms, which can produce a parse/syntax failure during SessionStart.

Fix: only apply length/trailing-backslash checks inside if defined GROK_HOME / if defined ORCA_GROK_HOME (mirror the POSIX script’s -n "$GROK_HOME" guard). Will open a focused PR with a unit assertion on the generated script.

innocarpe avatar Jul 23 '26 02:07 innocarpe

Reproduction status: env_blocked (Windows grok-hook.cmd / empty GROK_HOME)

Windows .cmd syntax when GROK_HOME is empty is OS-specific. macOS host cannot execute that batch path.

Not labeling cannot_repro.

nwparker avatar Jul 27 '26 05:07 nwparker

Duplicate of #9358.

Same root cause: managed grok-hook.cmd uses parse-time %GROK_HOME:~…% / %ORCA_GROK_HOME:~-1% substring expansion, which breaks when GROK_HOME is unset/empty and aborts SessionStart (and other hook events) with a cmd syntax error.

Unique context (reporter, @innocarpe claim, env_blocked note) transferred onto #9358. Tracking continues there.

AmethystLiang avatar Aug 04 '26 07:08 AmethystLiang