From 45b168f0156fdd98123fac465aab5f18548a5e37 Mon Sep 17 00:00:00 2001 From: Brian Madison Date: Wed, 13 May 2026 16:16:17 -0500 Subject: [PATCH] fix(bmad-prd): normalize status casing and add friendly file errors - compute_stats: lower-case `status` before bucketing so findings with any casing (e.g. "Pass") feed the stat buckets and the score bar fills correctly. Matches the .lower() pattern already used in render_finding and render_finding_md. - main: wrap findings/template read_text calls; emit a one-line error to stderr and return 1 on FileNotFoundError or JSONDecodeError instead of dumping a raw traceback. Script is LLM-invoked, so a clean diagnostic is the contract. Addresses augmentcode review comments 3235100013 and 3235100018. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../bmad-prd/scripts/render-validation-html.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/bmm-skills/2-plan-workflows/bmad-prd/scripts/render-validation-html.py b/src/bmm-skills/2-plan-workflows/bmad-prd/scripts/render-validation-html.py index 68adc799e..b89db9ae8 100644 --- a/src/bmm-skills/2-plan-workflows/bmad-prd/scripts/render-validation-html.py +++ b/src/bmm-skills/2-plan-workflows/bmad-prd/scripts/render-validation-html.py @@ -46,7 +46,7 @@ def compute_stats(findings: list[dict]) -> dict: failed_critical = 0 failed_high = 0 for f in findings: - status = f.get("status", "n/a") + status = (f.get("status") or "n/a").lower() if status in by_status: by_status[status] += 1 if status == "fail": @@ -219,8 +219,19 @@ def main(argv: list[str]) -> int: template_path = Path(args.template) output_path = Path(args.output) - data = json.loads(findings_path.read_text()) - template = template_path.read_text() + try: + data = json.loads(findings_path.read_text()) + except FileNotFoundError: + print(f"error: findings file not found: {findings_path}", file=sys.stderr) + return 1 + except json.JSONDecodeError as e: + print(f"error: findings file is not valid JSON ({findings_path}): {e}", file=sys.stderr) + return 1 + try: + template = template_path.read_text() + except FileNotFoundError: + print(f"error: template file not found: {template_path}", file=sys.stderr) + return 1 findings = data.get("findings", []) or []