{"record":{"id":"be3c20a0d7319e49","repo":"rohitg00/ai-engineering-from-scratch","slug":"join-errors","errorCode":null,"errorMessage":"; \".join(errors)","messagePattern":"; \"\\.join\\(errors\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"certifications/claude/lessons/12-claude-agent-sdk-and-hooks/code/main.py","lineNumber":219,"sourceCode":"            errors.append(\"computerUse network allowlist cannot be empty\")\n        if not isinstance(display, dict) or any(\n            not isinstance(display.get(field), int) or isinstance(display[field], bool) or display[field] <= 0\n            for field in (\"width\", \"height\")\n        ):\n            errors.append(\"computerUse display dimensions must be positive integers\")\n        if computer.get(\"requireFreshScreenshotBeforeAction\") is not True or computer.get(\"requireScreenshotAfterAction\") is not True:\n            errors.append(\"computerUse requires screenshots before and after actions\")\n        if not isinstance(computer.get(\"allowedActions\"), list) or \"screenshot\" not in computer[\"allowedActions\"]:\n            errors.append(\"computerUse needs an explicit action allowlist\")\n        if not isinstance(approval, dict) or not REQUIRED_APPROVAL_RISKS <= set(approval.get(\"requiredRiskClasses\", [])) or \"credential-entry\" not in set(approval.get(\"deniedRiskClasses\", [])):\n            errors.append(\"computerUse needs approval and denial risk boundaries\")\n    return errors\n\n\ndef evaluate_action(policy: dict[str, Any], tool_name: str, approved: bool) -> dict[str, Any]:\n    errors = validate_policy(policy)\n    if errors:\n        raise ValueError(\"; \".join(errors))\n    tool = next((item for item in policy[\"tools\"] if item[\"name\"] == tool_name), None)\n    if tool is None:\n        return {\"allowed\": False, \"reason\": \"unknown tool\"}\n    if tool.get(\"approvalPolicy\") == \"per-action\":\n        return {\"allowed\": False, \"reason\": \"per-action policy required\"}\n    if tool[\"approvalRequired\"] and not approved:\n        return {\"allowed\": False, \"reason\": \"approval required\"}\n    return {\"allowed\": True, \"reason\": \"policy and approval passed\"}\n\n\nclass ComputerUseGuard:\n    \"\"\"Validate model-proposed UI actions against trusted harness state.\"\"\"\n\n    def __init__(self, policy: dict[str, Any]) -> None:\n        errors = validate_policy(policy)\n        if errors:\n            raise ValueError(\"; \".join(errors))\n        self.config = policy[\"computerUse\"]","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/certifications/claude/lessons/12-claude-agent-sdk-and-hooks/code/main.py#L201-L237","documentation":"Error \"; \".join(errors)\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at certifications/claude/lessons/12-claude-agent-sdk-and-hooks/code/main.py:219 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}