From 96eac0e41aaccc4f378687313bc6ce1b0d152a00 Mon Sep 17 00:00:00 2001 From: Shayan Muhammad Date: Mon, 23 Nov 2026 01:41:52 +0500 Subject: [PATCH] docs(utils): reconcile bug_report path-free docstring and clarify redact_paths contract (#9644) --- syft/utils.py | 7 ++++--- tests/unit/test_bug_report.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 tests/unit/test_bug_report.py diff --git a/syft/utils.py b/syft/utils.py index 0a49e120691..204c13228af 100644 --- a/syft/utils.py +++ b/syft/utils.py @@ -655,12 +655,13 @@ def bug_report( OS details, Python configuration, virtual environments, package managers, installed packages, and Jupyter/Colab environment detection. - The output is safe to share: it prints only versions, paths, and config - metadata. No tokens, secrets, or sensitive credentials are included. + The output is safe to share: it prints only versions and config + metadata. No tokens, secrets, paths, or PII are included. Args: as_dict: If True, return the report as a dictionary instead of printing. - redact_paths: If True, redact user-specific paths in the output. + redact_paths: Kept for forward and backward compatibility. By design, + the generated report contains no user-specific paths or PII to redact. Returns: If as_dict is True, returns a dictionary containing all collected info. diff --git a/tests/unit/test_bug_report.py b/tests/unit/test_bug_report.py new file mode 100644 index 00000000000..937bbd702d9 --- /dev/null +++ b/tests/unit/test_bug_report.py @@ -0,0 +1,28 @@ +import io +import sys +from syft.utils import bug_report + + +def test_bug_report_as_dict(): + report = bug_report(as_dict=True) + assert isinstance(report, dict) + assert "syft" in report + assert "os_info" in report + assert "python_env" in report + + +def test_bug_report_redact_paths_compatibility(): + report_default = bug_report(as_dict=True, redact_paths=False) + report_redacted = bug_report(as_dict=True, redact_paths=True) + assert report_default == report_redacted + + +def test_bug_report_stdout_safe_notes(): + captured = io.StringIO() + old_stdout = sys.stdout + try: + sys.stdout = captured + bug_report(as_dict=False) + finally: + sys.stdout = old_stdout + assert "This report contains no tokens, secrets, paths, or PII." in captured.getvalue()