diff --git a/check_wcag_unique.py b/check_wcag_unique.py index 507d310..5d62662 100644 --- a/check_wcag_unique.py +++ b/check_wcag_unique.py @@ -39,9 +39,19 @@ def run_pa11y(url: str) -> List[dict]: print(f"[ERROR] pa11y failed with code {result.returncode} for {url}", file=sys.stderr) return [] + # Handle cases where pa11y writes nothing (or only whitespace) to stdout. + if result.stdout is None or not result.stdout.strip(): + if result.stderr: + # Forward pa11y’s stderr so you can inspect what happened. + print(result.stderr, file=sys.stderr) + print(f"[WARN] pa11y produced no JSON output for {url}", file=sys.stderr) + return [] + try: return json.loads(result.stdout) except json.JSONDecodeError: + # Show the raw (invalid) output to aid troubleshooting. + print(result.stdout, file=sys.stderr) print(f"[WARN] Could not parse pa11y JSON output for {url}", file=sys.stderr) return []