fix(model): resolve CLI exec paths for Windows .cmd shims - #250
fix(model): resolve CLI exec paths for Windows .cmd shims#250WODE25500 wants to merge 6 commits into
Conversation
- Resolve codex/claude/cursor/copilot exec paths via shutil.which at config load so bare npm .cmd shims spawn on Windows (bare 'codex' -> codex.CMD; CreateProcess does not search PATHEXT, so bare names raise WinError 2). - os.symlink uses target_is_directory + copytree/copy2 fallback (OfficeQA on Windows). - Add tests for _resolve_cli_path.
|
The CLI path-resolution change is useful, but the symlink fallback needs to fail closed before merge. In
The current OfficeQA caller generates unique There is also an incomplete redaction path introduced here: Copilot stdout/stderr is passed through |
Address maintainer review on microsoft#250: - prepare_workspace symlink fallback fails closed: re-raise when the destination already exists (lexists), never copytree into an existing dst, and only fall back for the Windows symlink-privilege-not-held error. Prevents a colliding extra_files or duplicate link_dirs entry from mutating source data outside the work dir. - Sanitize Copilot stdout/stderr structurally (mapping-key aware) so JSON objects carrying a token/secret field are redacted even when the value is a quoted mapping (which the string-level redactor missed). - Add tests: symlink privilege fallback, existing/duplicate dst, non-privilege re-raise, and Copilot JSONL secret-field redaction.
|
Yifan Yang (@Yif-Yang) — thank you for the thorough review and guidance! I've addressed the feedback:
Thanks again for the detailed review! |
|
Thanks — the symlink collision/source-mutation blocker is fixed. One Copilot redaction gap remains.
Please sanitize quoted/embedded JSON in the fallback path and add |
- Fold quoted-JSON whole-value capture into the shared _redact_cursor_error (run first) so a quoted value with spaces is scrubbed whole instead of truncating at the first space and leaking the remainder. One change covers the copilot fallback, the cursor stderr paths, and all string-leaf callers. - Regressions: prefixed/multiline quoted JSON, space-in-value, cursor parity.
- The substring regex over-scrubbed diagnostics like token_count / token_budget / secret_version. Decide with the project's endswith-based rule (matching _is_secret_mapping_key) so only real credential keys are redacted, while a quoted value that contains spaces is still captured whole. - Regressions: token-count diagnostic retention + nested secret key.
- Add "bearer" to the exact secret-key set so a standalone "bearer": <value> JSON key is scrubbed (the common "Authorization": "Bearer ..." form was already covered via the authorization key). - Regression: bare bearer key redaction.
|
Already addressed the review feedback and updated this branch (#250):
|
|
Thanks — the scalar prefixed cases are fixed, but two redaction gaps remain. |
…SON parsing - _redact_copilot_json now uses the same endswith-based _is_copilot_secret_key as the embedded-JSON fallback, so camelCase keys like githubToken are redacted. - Replace the single-level regex and line-by-line parsing with a bracket-matched, unbounded-nesting embedded-JSON scan, so deeply nested / pretty-printed JSON in non-JSON text is structurally redacted. - Add run-level regressions (success trace + error detail) for camelCase keys and deep-nested embedded JSON.
|
Thanks for the re-review. Addressed both redaction gaps: _redact_copilot_json now uses the same endswith-based _is_copilot_secret_key as the embedded-JSON fallback (so githubToken is redacted), and embedded JSON is parsed with an unbounded bracket-matching scan (deeply nested / pretty-printed JSON in non-JSON text is structurally redacted). Added run-level regressions for both the returned trace and the raised error. Commits 5a5a1f8. |
Cross-platform exec fixes for the model backends.
Verified: _resolve_cli_path('codex') -> codex.CMD on Windows; targeted tests pass.