Repository navigation
fix(service): keep % expansions out of parens in Windows scheduler wrapper (#6290) - #6406
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
cmd percent-expands variables while PARSING a ( ... ) block, before the line's condition is tested. A value containing ')' — a ko-KR/ja-JP %DATE% like "2026-09-30(수)", or an install path under "Program Files (x86)" — closed the block early and the parse error aborted the whole wrapper before the bun launch line, so the proxy silently never started on logon (Last Run Result stayed 0, RestartOnFailure never engaged). - token read, missing-install checks: single-line if/goto, no blocks - OCX_PKG_DIR resolved at generation time (win32.dirname^3 of cli) - restore_backup: pushd into the package parent so the for /f in-clause carries a literal glob; per-backup work moved to a :try_restore call - exit-code loop contract unchanged: 42 -> :stopped, else 5s cooldown Verified on real cmd.exe with a UTF-8 ko-KR-style %DATE%: old wrapper aborted with 'was unexpected at this time'; new wrapper restores the newest .ocx-backup-*, logs 'installation is incomplete' + exit 3 when unrecoverable, and runs the launch/restart/stay-out loop to exit 0. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Repository: lidge-jun/opencodex/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
…e token read
The flow comparator indexed the prefix-set boundary by the old
multi-line 'if exist "%OCX_API_TOKEN_FILE%" (' opener; the #6290
rewrite emits that check as one line, so expectedBoundary was -1 and
every generated standalone wrapper failed the chain walk.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. This PR stays in draft until every box above is ticked. |
|
Closing as superseded by #6391 ( An independent audit and the plan architect both checked Two parts of this PR should not land as written. The bracket-scan test counts parentheses inside quotes, so it fails on dev's correct wrapper. The |
Summary
Fixes the Windows Task Scheduler service wrapper dying at parse time on systems where a
%-expanded value contains)— most visibly ko-KR/ja-JP locales, where%DATE%expands like2026-09-30(수)(#6290, same defect class as #5093).cmd.exe percent-expands variables while parsing a
( ... )block, before the line's condition is ever tested. The wrapper'sif exist (...),if not exist (...), andfor /f ... in (...) do (...)blocks all embedded%OCX_API_TOKEN_FILE%,%OCX_PKG_DIR%,%OCX_CLI%, and timestamped%DATE% %TIME%echoes inside parentheses. A)inside any of those values closed the block early, the parse error aborted the whole batch before the bun launch line, and the proxy silently never started on logon — Task Scheduler's Last Run Result stayed 0 so RestartOnFailure never engaged.buildWindowsServiceScriptnow keeps every%VAR%expansion out of parentheses:if/goto, no blocks.OCX_PKG_DIRresolved at generation time (win32.dirname^3 ofcli) instead offor %%I in ("%OCX_CLI%\..\..\..")— which both put a%inside parens and could not survive a)in the install path. Still defined when the package tree is gone, which is exactly the restore scenario.call :restore_backupunchanged; inside it,pushd "%OCX_PKG_DIR%\.."first so thefor /fin-clause carries only a literal.ocx-backup-*glob, and the per-backup work is acalled:try_restoresubroutine instead of a nested parenthesized body.:missing_bun/:missing_clilabels hold theinstallation is incompletelog +exit /b 3paths.42→:stopped/endlocal/exit /b 0; anything else → log +ping -n 65s cooldown →goto loop.matchesGeneratedStandaloneControlFlowalso recognizes the new single-line token read, preserving standalone-wrapper ownership detection.ocx service repairalready rewrites these assets unconditionally on the scheduler backend, so existing installs pick up the fixed wrapper on repair/update.Verification
bun test tests/windows/windows-service-wrappers.test.ts— 17 pass, incl. two new tests: a scan asserting no%inside any(...)region of both generated variants, and a win32 test that runs the generated wrapper under realcmd.exewith a UTF-8set "DATE=2026-09-30(수)"shadow (expects cleanexit 3+ theinstallation is incompletelog line, not a parse abort).bun test tests/service/service.test.ts tests/service/standalone-service.test.ts— 209 pass, 3 platform skips.bun run typecheck,bun run privacy:scan,bun run structure:check— all pass.cmd.exeA/B on this Windows box, both generated wrappers under the simulated ko-KR%DATE%:14:35:44.67] was unexpected at this time.— parse abort mid-restore block (repro of [Bug][Windows] Service wrapper still aborts before launching bun when %DATE% contains parentheses (ko-KR) — #5093 unfixed in 2.73.0 #6290).no restorable backup found→installation is incomplete: bundled Bun is missing→exit 3; with.ocx-backup-*dirs present →restored previous install from .ocx-backup-20260102(newest first) and package dir repopulated; with a real exe child →child exited with code 0; restarting in 5s→ cooldown → relaunch → exit42→:stopped→exit 0.bun run testsuite and GUI/Rust gates (changed surface is the service wrapper, service-manager probe, and tests; nogui/ordesktop/changes, so no screenshots).CI follow-up
bun test tests/codex-service-manager-probe.test.tspassed 89 tests and typecheck passed.macos 1/2,owner-registry-acl.test.ts(registry publication requires the owner-only Windows directory ACL) returns an emptyhomeslist. The aggregatecigate fails with it. The corresponding 6 tests pass locally on Windows. A macOS path/no-follow issue is a hypothesis, not a confirmed root cause; no clean-base reproduction or same-revision successful retry establishes flakiness. This remains unresolved, and the PR is not fully green.Checklist
Link to Devin session: https://app.devin.ai/sessions/641ad09cbb8f48b3a44bc2c65cd6d82f
Open in Devin Desktop: https://app.devin.ai/desktop/session/641ad09cbb8f48b3a44bc2c65cd6d82f?variant=devin
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.