{"record":{"id":"977affd2e0caf3f9","repo":"SeleniumHQ/selenium","slug":"event-event-not-found-available-events-self","errorCode":null,"errorMessage":"Event '{event}' not found. Available events: {self._available_events}","messagePattern":"Event '(.+?)' not found\\. Available events: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py/private/_event_manager.py","lineNumber":109,"sourceCode":"\n    def __init__(self, conn, event_configs: dict[str, EventConfig]):\n        self.conn = conn\n        self.event_configs = event_configs\n        self.subscriptions: dict = {}\n        self._event_wrappers = {}  # Cache of _EventWrapper objects\n        self._bidi_to_class = {config.bidi_event: config.event_class for config in event_configs.values()}\n        self._available_events = \", \".join(sorted(event_configs.keys()))\n        self._subscription_lock = threading.Lock()\n\n        # Create event wrappers for each event\n        for config in event_configs.values():\n            wrapper = _EventWrapper(config.bidi_event, config.event_class)\n            self._event_wrappers[config.bidi_event] = wrapper\n\n    def validate_event(self, event: str) -> EventConfig:\n        event_config = self.event_configs.get(event)\n        if not event_config:\n            raise ValueError(f\"Event '{event}' not found. Available events: {self._available_events}\")\n        return event_config\n\n    def subscribe_to_event(self, bidi_event: str, contexts: list[str] | None = None) -> None:\n        \"\"\"Subscribe to a BiDi event if not already subscribed.\"\"\"\n        with self._subscription_lock:\n            if bidi_event not in self.subscriptions:\n                session = Session(self.conn)\n                result = session.subscribe([bidi_event], contexts=contexts)\n                sub_id = result.get(\"subscription\") if isinstance(result, dict) else None\n                self.subscriptions[bidi_event] = {\n                    \"callbacks\": [],\n                    \"subscription_id\": sub_id,\n                }\n\n    def unsubscribe_from_event(self, bidi_event: str) -> None:\n        \"\"\"Unsubscribe from a BiDi event if no more callbacks exist.\"\"\"\n        with self._subscription_lock:\n            entry = self.subscriptions.get(bidi_event)","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/private/_event_manager.py#L91-L127","documentation":"Raised as a ValueError by _EventManager.validate_event() when the event name passed to it is not a key in the event_configs dictionary. The manager holds a registry of supported events (built from EventConfig entries) and computes _available_events as a sorted, comma-joined string for the error message. Calling validate_event with an unregistered event name is a usage error indicating the event is not part of this BiDi module's supported event set.","triggerScenarios":"Calling an event-validation entry point (e.g. add_event_listener or callback registration on a generated BiDi module) with an event string that does not match any key in that module's event_configs. The message includes the sorted list of valid event names for diagnostics.","commonSituations":"Misspelling an event name (e.g. 'responceStarted' instead of 'responseStarted'); using an event name from a different BiDi module than the one being called; version mismatch where an event was renamed in a newer Selenium release; mixing up camelCase vs snake_case event identifiers.","solutions":["Read the 'Available events' portion of the error message — it lists the exact valid event names for this module.","Copy the exact event name string from the available events list into your code to avoid spelling or casing mismatches.","Confirm you are calling the method on the correct BiDi module (e.g. network events on the network module, log events on the log module).","Check the Selenium version's API docs for renamed or newly added events if upgrading."],"exampleFix":"# before\nmanager.validate_event('responceStarted')  # typo\n\n# after\nmanager.validate_event('responseStarted')  # from available events list","handlingStrategy":"validation","validationCode":"# Validate before calling\nvalid_events = set(manager.event_configs.keys())\nif event_name not in valid_events:\n    raise ValueError(f'Use one of: {sorted(valid_events)}')\nmanager.validate_event(event_name)","typeGuard":null,"tryCatchPattern":"try:\n    manager.validate_event(event_name)\nexcept ValueError as e:\n    if 'not found' in str(e):\n        # read available events from the message and correct\n        pass\n    else:\n        raise","preventionTips":["Read the Available events list from the error message for valid names.","Use constants or enums for event names rather than string literals to avoid typos.","Confirm the event belongs to the correct BiDi module."],"tags":["python","bidi","events","validation","event-manager"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}