fix: emit one separator style in --json path fields on Windows - #125
Merged
Conversation
A Windows `--json` envelope mixed separator styles: the typed local path fields (`file`, `path`, `output`, `workdir`, the `job` step paths, ...) came out with `\`, while human-facing messages, remote printer paths, and archive entries in the same document used `/`. A consumer could not compare or join two path fields without knowing which side produced each one. `utils._json_display_paths` already funnels every declared path key through one hook, so the fix goes there rather than at each call site: add `paths.json_path()` (separator normalization only) and apply it after the existing `~` compaction. `local_path` was the one declared local-path contract field missing from `_JSON_PATH_KEYS`; it is now covered. Home-directory `~` compaction is deliberately kept. It is a documented privacy guarantee (AGENTS.md, docs/api.md) that `tests/privacy_smoke.py` actively enforces, and `~` stays expandable via `paths.expand_path`. URL-valued path fields keep their own separators and their redaction. No behaviour change on macOS/Linux, where `os.sep` is already `/`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Windows
--jsonenvelope mixed separator styles. The typed local path fields (file,path,output,workdir, thejobstep paths, …) came out with\, while human-facing messages, remote printer paths, and archive entries in the same document used/. A consumer could not compare or join two path fields without knowing which side produced each one.Reproduced on
mainbefore changing anything:Approach
utils._json_display_pathsalready funnels every declared path key through one hook, so this is a one-place fix rather than a per-call-site sweep:paths.json_path()— separator normalization only — applied after the existing~compaction.local_pathto_JSON_PATH_KEYS. It was the one declared local-path contract field not covered (currently dormant, but reachable viaJobOk).URL-valued path fields keep their own separators and their redaction. Remote printer paths and archive entries are untouched. No behaviour change on macOS/Linux, where
os.sepis already/.~compaction is deliberately keptAn earlier plan for this fix called for dropping the tilde-shortening so agents get directly openable paths. That would have leaked the username into every envelope:
~compaction in JSON is a documented privacy guarantee (AGENTS.md,docs/api.md:55) thattests/privacy_smoke.pyactively enforces by scanning output for$USERNAMEand/Users/<name>.~also stays openable —paths.expand_pathreverses it, and it is the form the CLI already accepts. This PR fixes the separator inconsistency only.Verification (Windows, Python 3.11)
-W error::ResourceWarning,--cov-fail-under=86): 1497 passed, 5 skipped, 1 deselected (live). Was 1494 onmain; +3 new regression tests.ruff@0.16.0 checkandformat --check: pass (94 files).bandit@1.9.4 -ll: 0 medium, 0 high.privacy_smoke.py.scripts/gen_schemas.pyproduces no diff — no schema drift.The new tests in
tests/test_jsonio.pymonkeypatchos.sep, so they pin the Windows contract on any host rather than passing vacuously on Linux CI.