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) <noreply@anthropic.com>
This commit is contained in:
parent
2ae3ddfee4
commit
45b168f015
|
|
@ -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 []
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue