Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

fix(docs-check): preserve Mintlify output on Windows (#1579)

Wu Shuwenf36a26457160
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9070ec51..c5c03d4d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -120,6 +120,7 @@ jobs:
print('semantica', semantica.__version__, 'core installed and importable')
"
pytest -q tests/test_issue_1513_slim_core.py
+ pytest -q tests/test_docs_check.py
- name: Install Explorer backend test dependencies
run: |
# Run the deterministic backend path before the all-extras CI
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
index a0de4e1f..c51f6332 100644
--- a/.github/workflows/codeql.yml
+++ b/.github/workflows/codeql.yml
@@ -34,7 +34,7 @@ jobs:
# meaningful state carried over from a failed attempt.
- name: Initialize CodeQL (attempt 1)
id: codeql-init-1
- uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
+ uses: github/codeql-action/init@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4
continue-on-error: true
with:
languages: python
@@ -44,7 +44,7 @@ jobs:
- name: Initialize CodeQL (attempt 2)
id: codeql-init-2
if: steps.codeql-init-1.outcome == 'failure'
- uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
+ uses: github/codeql-action/init@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4
continue-on-error: true
with:
languages: python
@@ -54,17 +54,17 @@ jobs:
- name: Initialize CodeQL (attempt 3)
id: codeql-init-3
if: steps.codeql-init-2.outcome == 'failure'
- uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
+ uses: github/codeql-action/init@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4
with:
languages: python
queries: security-and-quality
config-file: .github/codeql/codeql-config.yml
- name: Autobuild
- uses: github/codeql-action/autobuild@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
+ uses: github/codeql-action/autobuild@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
+ uses: github/codeql-action/analyze@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4
with:
category: "/language:python"
upload: false
@@ -74,7 +74,7 @@ jobs:
# Uploads results only when Default Setup is not active.
# If Default Setup is still enabled, this step skips gracefully
# instead of failing the workflow with HTTP 409.
- uses: github/codeql-action/upload-sarif@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
+ uses: github/codeql-action/upload-sarif@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4
with:
sarif_file: ${{ steps.codeql.outputs.sarif-output }}
category: "/language:python"
diff --git a/.github/workflows/container-scan.yml b/.github/workflows/container-scan.yml
index 918345bc..5bd8c0a1 100644
--- a/.github/workflows/container-scan.yml
+++ b/.github/workflows/container-scan.yml
@@ -61,7 +61,7 @@ jobs:
- name: Upload Trivy SARIF
if: always()
- uses: github/codeql-action/upload-sarif@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
+ uses: github/codeql-action/upload-sarif@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4
with:
sarif_file: trivy-results.sarif
category: trivy-container
diff --git a/.github/workflows/defender-for-devops.yml b/.github/workflows/defender-for-devops.yml
index 8b48b5fb..f3b6f688 100644
--- a/.github/workflows/defender-for-devops.yml
+++ b/.github/workflows/defender-for-devops.yml
@@ -59,7 +59,7 @@ jobs:
# avoiding the guardian.cmd/checkov exit-code bug in the MSDO wrapper.
tools: eslint,templateanalyzer,terrascan
- name: Upload results to Security tab
- uses: github/codeql-action/upload-sarif@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
+ uses: github/codeql-action/upload-sarif@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4
with:
sarif_file: ${{ steps.msdo.outputs.sarifFile }}
@@ -100,7 +100,7 @@ jobs:
run: python .github/scripts/filter_checkov_skipped.py reports/results_json.json reports/results_sarif.sarif reports/checkov.sarif
- name: Upload Checkov results to Security tab
- uses: github/codeql-action/upload-sarif@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
+ uses: github/codeql-action/upload-sarif@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4
if: always()
with:
sarif_file: reports/checkov.sarif
diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml
index 8f5d57ae..b4d2d71c 100644
--- a/.github/workflows/scorecard.yml
+++ b/.github/workflows/scorecard.yml
@@ -40,6 +40,6 @@ jobs:
retention-days: 5
- name: Upload to code-scanning
- uses: github/codeql-action/upload-sarif@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
+ uses: github/codeql-action/upload-sarif@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4
with:
sarif_file: results.sarif
diff --git a/docs_check.py b/docs_check.py
index 7f0ede1f..ba0e7529 100644
--- a/docs_check.py
+++ b/docs_check.py
@@ -236,6 +236,8 @@ def _() -> list[str]:
cwd=DOCS,
capture_output=True,
text=True,
+ encoding="utf-8",
+ errors="replace",
timeout=600,
)
# Clean up zip regardless of outcome
diff --git a/tests/test_docs_check.py b/tests/test_docs_check.py
new file mode 100644
index 00000000..015e85f1
--- /dev/null
+++ b/tests/test_docs_check.py
@@ -0,0 +1,83 @@
+"""Regression tests for the standalone documentation checker."""
+
+import runpy
+import subprocess
+import sys
+from pathlib import Path
+
+
+def test_mintlify_export_uses_utf8_lossy_capture(monkeypatch):
+ """Mintlify output remains available regardless of the host code page.
+
+ Verifies that:
+ - subprocess.run is called with encoding="utf-8" and errors="replace"
+ - The Windows EPERM noise filter fires correctly when output is captured
+ (i.e. result.stdout is non-empty and "EPERM" reaches the filter)
+ """
+ calls = []
+
+ def fake_run(command, **kwargs):
+ calls.append((command, kwargs))
+ return subprocess.CompletedProcess(
+ command,
+ 1,
+ stdout="cleanup EPERM",
+ stderr="",
+ )
+
+ monkeypatch.setattr(subprocess, "run", fake_run)
+ monkeypatch.setattr(sys, "platform", "win32")
+
+ # docs_check.py calls sys.exit(1) when any check fails. If the EPERM
+ # noise filter cannot see stdout (because it was None / lost), the
+ # Mintlify check reports a failure and sys.exit(1) is raised here.
+ runpy.run_path(
+ str(Path(__file__).parents[1] / "docs_check.py"),
+ run_name="__main__",
+ )
+
+ assert calls, "the Mintlify export check did not invoke subprocess.run"
+ _, kwargs = calls[-1]
+ assert kwargs["encoding"] == "utf-8", (
+ "subprocess.run must use explicit UTF-8 encoding; "
+ "without it the Windows locale codec silently discards Mintlify output"
+ )
+ assert kwargs["errors"] == "replace", (
+ "errors='replace' is required so invalid bytes produce U+FFFD "
+ "instead of raising UnicodeDecodeError and losing the entire stream"
+ )
+
+
+def test_utf8_bytes_survive_capture():
+ """Bytes valid in UTF-8 but invalid in Windows cp1252 must not be lost.
+
+ This is the minimal reproduction from issue #1578: the three bytes
+ 0xe2 0xa0 0x8f encode U+2800 (BRAILLE PATTERN BLANK) in UTF-8 but are
+ not representable in cp1252. Without encoding="utf-8" the subprocess
+ reader thread raises UnicodeDecodeError and result.stdout becomes None,
+ making combined == "" and the EPERM/EBUSY noise filter unreachable.
+ """
+ code = (
+ "import sys; "
+ "sys.stdout.buffer.write(bytes([0xe2, 0xa0, 0x8f])); "
+ "sys.stdout.flush()"
+ )
+ result = subprocess.run(
+ [sys.executable, "-c", code],
+ capture_output=True,
+ text=True,
+ encoding="utf-8",
+ errors="replace",
+ )
+ assert result.returncode == 0
+ assert result.stdout is not None, (
+ "stdout must not be None; a UnicodeDecodeError in the reader thread "
+ "would have discarded the entire captured stream"
+ )
+ # The three bytes decode to a single Unicode character (U+280F); with
+ # errors="replace" any truly undecodable byte would become U+FFFD instead.
+ # Either way the stream is preserved rather than lost — that is the fix.
+ assert len(result.stdout.strip()) == 1, (
+ "expected exactly one decoded character; "
+ "an empty result means the stream was silently lost"
+ )