MCPcopy
hub / github.com/zappa/Zappa / validate_registry

Function validate_registry

zappa/websocket.py:172–193  ·  view source on GitHub ↗

Validate that all required routes are registered. Raises WebSocketConfigurationError if handlers are registered but required routes ($connect, $default) are missing.

()

Source from the content-addressed store, hash-verified

170
171
172def validate_registry():
173 """Validate that all required routes are registered.
174
175 Raises WebSocketConfigurationError if handlers are registered
176 but required routes ($connect, $default) are missing.
177 """
178 global _validated
179 if _validated:
180 return
181 _validated = True
182
183 if not _registry:
184 return
185
186 missing = REQUIRED_ROUTES - set(_registry.keys())
187 if missing:
188 route_to_decorator = {"$connect": "@on_connect", "$default": "@on_message"}
189 missing_names = ", ".join(route_to_decorator.get(r, r) for r in sorted(missing))
190 raise WebSocketConfigurationError(
191 f"WebSocket handlers registered but missing required routes: {missing_names}. "
192 f"All WebSocket apps must define handlers for $connect and $default ($disconnect is optional)."
193 )
194
195
196class WebSocketConfigurationError(Exception):

Calls 1