{"record":{"id":"428b6260dc2ebb53","repo":"HelloZeroNet/ZeroNet","slug":"here-is-your-console","errorCode":null,"errorMessage":"Here is your console","messagePattern":"Here is your console","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/Ui/UiRequest.py","lineNumber":879,"sourceCode":"            self.sendHeader()\n            return [b\"No error! :)\"]\n\n    # Just raise an error to get console\n    def actionConsole(self):\n        import sys\n        sites = self.server.sites\n        main = sys.modules[\"main\"]\n\n        def bench(code, times=100, init=None):\n            sites = self.server.sites\n            main = sys.modules[\"main\"]\n            s = time.time()\n            if init:\n                eval(compile(init, '<string>', 'exec'), globals(), locals())\n            for _ in range(times):\n                back = eval(code, globals(), locals())\n            return [\"%s run: %.3fs\" % (times, time.time() - s), back]\n        raise Exception(\"Here is your console\")\n\n    # - Tests -\n\n    def actionTestStream(self):\n        self.sendHeader()\n        yield \" \" * 1080  # Overflow browser's buffer\n        yield \"He\"\n        time.sleep(1)\n        yield \"llo!\"\n        # yield \"Running websockets: %s\" % len(self.server.websockets)\n        # self.server.sendMessage(\"Hello!\")\n\n    # - Errors -\n\n    # Send bad request error\n    def error400(self, message=\"\"):\n        self.sendHeader(400, noscript=True)\n        self.log.error(\"Error 400: %s\" % message)","sourceCodeStart":861,"sourceCodeEnd":897,"githubUrl":"https://github.com/HelloZeroNet/ZeroNet/blob/454c0b2e7e000fda7000cba49027541fbf327b96/src/Ui/UiRequest.py#L861-L897","documentation":"actionConsole is a built-in developer console endpoint that eval()s arbitrary code sent by the UI. After executing, it deliberately raises Exception('Here is your console') to terminate the request — this 'error' is the control-flow mechanism used to end the console response, not a real failure. It only occurs when the console feature is used (typically when enabled for local development).","triggerScenarios":"Calling the UiWebsocket/UiRequest console action (e.g. via the ZeroNet console UI or POSTing to the console route); the exception is raised intentionally after the eval loop returns its result.","commonSituations":"Developers using ZeroNet's interactive console during development; automated tests or scripts hitting the console endpoint; production deployments that accidentally left the console enabled.","solutions":["Treat this exception as the console's normal response terminator and read the computed result from the response body, not the exception","Disable/avoid exposing actionConsole in production; guard it behind authentication or remove the route","If wrapping requests in try/except, whitelist this message so it isn't reported as a failure","Upgrade or patch UiRequest so the console returns its result directly instead of raising"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = request_console(code)\nexcept Exception as e:\n    if \"Here is your console\" in str(e):\n        pass  # expected control-flow termination, handle result normally\n    else:\n        raise","preventionTips":["Do not enable the console endpoint in production builds","Whitelist this message in error reporting/monitoring","Treat console responses as data, not failures","Wrap console calls in a helper that swallows this specific exception"],"tags":["console","control-flow","security"],"backgroundTag":"console-error-by-design","analyzedSha":"454c0b2e7e000fda7000cba49027541fbf327b96","analyzedAt":"2026-09-02T19:46:57.278Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}