{"record":{"id":"5b1b16ca7e52e12d","repo":"rohitg00/ai-engineering-from-scratch","slug":"os-system-denied","errorCode":null,"errorMessage":"os.system denied","messagePattern":"os\\.system denied","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"error","filePath":"phases/19-capstone-projects/72-code-exec-metric/code/main.py","lineNumber":84,"sourceCode":"import builtins as _builtins\n\n_DENIED_MODULES = {\n    'subprocess', 'socket', 'shutil', 'requests', 'urllib',\n    'urllib.request', 'urllib.error', 'urllib.parse', 'ctypes',\n    'http.client', 'asyncio.subprocess',\n}\n\n_real_import = _builtins.__import__\ndef _guarded_import(name, *args, **kwargs):\n    base = name.split('.')[0]\n    if name in _DENIED_MODULES or base in _DENIED_MODULES:\n        raise ImportError(\"denied module: %s\" % name)\n    return _real_import(name, *args, **kwargs)\n_builtins.__import__ = _guarded_import\n\nimport os as _os\ndef _denied_system(_cmd):\n    raise OSError(\"os.system denied\")\n_os.system = _denied_system\n\nCODE = __PLACEHOLDER_CODE__\nASSERTIONS = __PLACEHOLDER_ASSERTIONS__\n\nns = {}\nstatus = {\"exit_code\": \"pass\", \"results\": [], \"detail\": \"\"}\ntry:\n    compiled = compile(CODE, \"<candidate>\", \"exec\")\nexcept SyntaxError as exc:\n    status[\"exit_code\"] = \"syntax_error\"\n    status[\"detail\"] = \"SyntaxError: %s\" % exc\n    sys.stdout.write(json.dumps(status))\n    sys.exit(0)\nexcept Exception as exc:\n    status[\"exit_code\"] = \"error\"\n    status[\"detail\"] = \"compile error: %r\" % exc\n    sys.stdout.write(json.dumps(status))","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/19-capstone-projects/72-code-exec-metric/code/main.py#L66-L102","documentation":"Error \"os.system denied\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/19-capstone-projects/72-code-exec-metric/code/main.py:84 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"}