From 9d37c46bb3284776dd4736654df33a226b4387bf Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 11 Nov 2026 14:40:17 +0100 Subject: [PATCH] fix: hide host paths in probe logs and errors MAME logs the folder above the content's ("Parent path"), which no place named, and a pack probe kept core_probe's traceback with the checkout spelled out. The first is written /.., the second , and , replaced before the error is cut. --- scripts/core_probe.py | 6 +++++- scripts/pack_probe.py | 8 +++++++- tests/test_pack_probe.py | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/scripts/core_probe.py b/scripts/core_probe.py index d58142c78..3af6fbdfe 100644 --- a/scripts/core_probe.py +++ b/scripts/core_probe.py @@ -965,7 +965,11 @@ def run_once(args: argparse.Namespace, system_dir: Path, scratch: Path, state_ou result["exit"] = exit_description(proc.returncode) places = [(str(system_dir.resolve()), ""), (str(save_dir.resolve()), "")] if args.content: - places.append((str(Path(args.content).resolve().parent), "")) + folder = Path(args.content).resolve().parent + # MAME prints the folder above the content's too ("Parent path"). + places.append((str(folder), "")) + if folder.parent != folder.parent.parent: + places.append((str(folder.parent), "/..")) places.append((str(ROOT), "")) for line in result.get("logs", []): line["text"] = host_paths_hidden(line["text"], places) diff --git a/scripts/pack_probe.py b/scripts/pack_probe.py index e901421a8..14a84a29c 100644 --- a/scripts/pack_probe.py +++ b/scripts/pack_probe.py @@ -508,7 +508,13 @@ def core_probe(argv: list[str], staged: set[str], layout: Layout, work: Path) -> record = json.loads(proc.stdout) except ValueError: record = None - return proc.returncode, record, proc.stderr.strip()[-1500:] + # A traceback spells the checkout and the scratch folders: a record read + # on another machine names them by role. + places = [(str(work), ""), (str(layout.root), ""), (str(ROOT), "")] + error = proc.stderr.strip() + for prefix, name in sorted(places, key=lambda place: -len(place[0])): + error = error.replace(prefix, name) + return proc.returncode, record, error[-1500:] def probe_argv(core: dict, choice: CoreChoice, content: campaign.Content, load: Path, diff --git a/tests/test_pack_probe.py b/tests/test_pack_probe.py index a55a08581..f68a017bd 100644 --- a/tests/test_pack_probe.py +++ b/tests/test_pack_probe.py @@ -299,6 +299,23 @@ class RecordsNameNoLocalPath(unittest.TestCase): self.assertEqual(summary, "Copy it from an owned copy of the game into /jazz2/Source/. " "Saves go to .") + def test_a_probe_error_names_the_checkout(self) -> None: + """A core_probe traceback spelled the worktree it ran from.""" + import subprocess + import unittest.mock + + work = TMP / "error-paths" + script = pp.ROOT / "scripts" / "core_probe.py" + + def fake_run(command, **kwargs): + return subprocess.CompletedProcess(command, 1, "", f' File "{script}", line 9\n') + + with unittest.mock.patch.object(pp, "PROBE_LOCK", work / "probe.lock"), \ + unittest.mock.patch.object(pp.subprocess, "run", fake_run): + code, record, error = pp.core_probe(["run"], set(), layout({}), work) + self.assertEqual((code, record), (1, None)) + self.assertEqual(error, 'File "/scripts/core_probe.py", line 9') + def test_no_committed_record_holds_a_local_path(self) -> None: """Ten records cut at 400 characters inside the scratch path kept its tail, which no absolute-path pattern sees."""