rohitg00/ai-engineering-from-scratch · error · ValueError
packet root must be an object
Error message
packet root must be an object
What it means
Error "packet root must be an object" thrown in rohitg00/ai-engineering-from-scratch.
Source
Thrown at certifications/claude/lessons/06-governance-safety-and-responsible-use/code/main.py:72
errors.append("approvalPacket needs an authorizedRole")
if approval.get("untrustedContentCanAuthorize") is not False:
errors.append("untrusted content cannot authorize action")
for field in ("decision", "evidence", "uncertainty"):
if not str(approval.get(field, "")).strip():
errors.append(f"approvalPacket.{field} is required")
return errors
def score_control_map(packet: dict[str, Any]) -> dict[str, Any]:
errors = validate_control_map(packet)
control_count = 3 * len(packet.get("risks", [])) if isinstance(packet.get("risks"), list) else 0
return {"passed": not errors, "errors": errors, "controlCount": control_count, "reviewRequired": review_required(packet.get("consequence", "high"), bool(packet.get("reversible"))), "confidenceDoesNotAuthorize": True}
def load_packet(path: Path) -> dict[str, Any]:
value = json.loads(path.read_text(encoding="utf-8"))
if not isinstance(value, dict):
raise ValueError("packet root must be an object")
return value
if __name__ == "__main__":
path = Path(__file__).parents[1] / "outputs" / "responsible-use-control-map.json"
print(json.dumps(score_control_map(load_packet(path)), indent=2))
View on GitHub (pinned to 39ea8a1c6d)
When it happens
Trigger: Thrown at certifications/claude/lessons/06-governance-safety-and-responsible-use/code/main.py:72 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26).
Data as JSON: /api/errors/a1e24f181a58b3f9.
Report an issue: GitHub.