The gRPC error boundary¶
How an exception raised inside a node becomes the response its caller receives (SDK 2.42.0): the single conversion every unary RPC funnels its failures through, the error-code to gRPC-status table that is the wire contract, and the asymmetric scrubbing that keeps a private error's status accurate while dropping its detail. The node-author view is Errors; the class listing is on the Errors reference.
Where it sits¶
_handle_rpc in api/grpc/router/node_router.py wraps every unary RPC body. Its except calls to_neura_grpc_error(exc, logger, context, error_message_prefix), so there is exactly one place where an exception turns into a NeuraGrpcError. Before 2.42.0 that same except built a NeuraPublicRuntimeError with the stringified exception in its message, which is why a node's internal detail used to reach the caller verbatim and no failure carried a status of its own.
Two paths exist inside the conversion:
| Exception | Path |
|---|---|
NodeError or SDKError |
Status from STATUS_BY_CODE or the type defaults, then kept whole or scrubbed according to is_public() |
Anything else, including already-public library errors such as NeuraPublicValidationError and plain exceptions |
Handed to NeuraGrpcError.from_error_or_exception, which preserves public errors and reduces unsafe ones to a generic INTERNAL |
What the boundary does and does not reach¶
The boundary only exists on the unary RPC path, which is narrower than it first looks. on_execute is outside it:
| Hook | Reaches the boundary through |
|---|---|
on_configure, on_stop, on_pause, on_resume, on_health_check, on_toggle_simulation_mode, on_get_configuration |
The corresponding RPC, synchronously. configure() re-raises the original exception, so the vocabulary survives |
on_execute |
Nothing. A run is queued by the trigger adapter (_submit_execute) or by RunNode, which calls execute_node_background() and returns as soon as the thread starts |
NodeController.execute_node(), the synchronous variant that would reach the boundary, has no caller in 2.42.0.
So an on_execute failure surfaces in three places, none of them scrubbed: the ERROR log line, the ERROR state on the status stream, and ErrorInformation(err_type=str(type(e)), err_msg=str(e)) on the Error trigger, which is serialized with model_dump_json() and published to the downstream nodes. The developer message of a private error is on that payload verbatim. That predates the vocabulary, which changed only the class name in err_type, but it is the gap to close if private-by-default is to mean the same thing on both paths.
NodeBase.execute() used to flatten the vocabulary
It wrapped every exception from on_execute in NodeExecutionError, a NodeSDKError, which takes the second path in the table above. Since 2.42.0 a NodeError is re-raised unchanged. The visible effect today is an accurate err_type on the Error trigger and the right class for an author's own except; it also means the vocabulary already works if a synchronous execute RPC is ever wired up.
One interaction to keep in mind: _run_node_with_retry and _configure_node_with_retry are wrapped in a tenacity @retry keyed on is_retryable. Now that a NodeError can carry that flag and reach the router, a retryable error raised from on_configure makes the router run configure_node a second time. The guide tells authors not to mark input errors retryable, which is what keeps this benign.
Status resolution¶
status_for(exc) collects the codes on the exception that appear in STATUS_BY_CODE. When several match, the most specific wins by _PRECEDENCE order (INVALID_ARGUMENT, FAILED_PRECONDITION, NOT_FOUND, RESOURCE_EXHAUSTED, DEADLINE_EXCEEDED, UNAVAILABLE, INTERNAL) rather than the first or the worst, so an error that is both invalid input and a failed precondition reports INVALID_ARGUMENT, the one that tells the caller most about what to fix. error_codes is a set, so there is no first.
When no code matches, _default_status_by_type resolves from the class, ordered most specific first because both hierarchies narrow from their base downwards.
Codes absent from the table are absent by design: they carry no status distinction of their own, so every entry in it earns its place by saying something the class default does not.
Scrubbing¶
Scrubbing is asymmetric, and that asymmetry is the whole point. A private error keeps an accurate status but loses its message, its error codes and its labels; the caller gets a transaction id pointing at the log line that still has all of it. A private error does keep is_retryable and retry_hint_min_wait_ms, because both are advice about what to do next rather than detail about what went wrong.
_build_private_error logs before it scrubs, which makes the logger a hard dependency: it must not be None for a private error or the detail is gone for good.
The module¶
::: neuraverse_sdk.api.grpc.error_boundary options: heading_level: 3 members_order: source show_root_heading: false show_root_toc_entry: false
Specifications and tests¶
- In-process specs:
specifications/specs/grpc-routing/035-node-sdk-error-boundary.feature(public SDK error kept whole, private node error scrubbed with an accurate status, user message forwarded,as_public()honoured) and030-error-wrapping.feature. - Unit tests:
tests/errors/test_sdk_errors.py,tests/errors/test_node_errors.py,tests/errors/test_retry.py,tests/test_node_router.py. tests/errors/test_docstrings.pyholds theSTATUS_BY_CODEdocstring table to the mapping row for row, because that table is the published wire contract.
SDK-raised factory table (authors catch these; the SDK does not raise them yet):
SDKLifecycleError: A lifecycle transition or mode change could not be completed.
| Factory | Error code | gRPC status | Raise it when | Caller sees by default |
|---|---|---|---|---|
SDKLifecycleError.invalid_state(msg) |
err.sdk.lifecycle.invalid_state |
FAILED_PRECONDITION |
The node's current state does not allow the requested operation. | The node is in an invalid state for this operation. |
SDKLifecycleError.initialize(msg) |
err.sdk.lifecycle.initialize |
INTERNAL |
Initialization failed - the node class could not be brought into existence. | Node initialization failed. |
SDKLifecycleError.configure(msg) |
err.sdk.lifecycle.configure |
INTERNAL |
Configuration failed - on_configure raised, or the SDK could not apply it. |
Node configuration failed. |
SDKLifecycleError.execute(msg) |
err.sdk.lifecycle.execute |
INTERNAL |
Execution failed - the run path raised before or inside on_execute. |
Node execution failed. |
SDKLifecycleError.stop(msg) |
err.sdk.lifecycle.stop |
INTERNAL |
Stopping failed - the node may be left holding resources. | Node stop failed. |
SDKLifecycleError.pause(msg) |
err.sdk.lifecycle.pause |
INTERNAL |
Pausing failed - on_pause raised. |
Node pause failed. |
SDKLifecycleError.resume(msg) |
err.sdk.lifecycle.resume |
INTERNAL |
Resuming failed - on_resume raised. |
Node resume failed. |
SDKLifecycleError.mode(msg) |
err.sdk.lifecycle.mode |
INTERNAL |
A mode change failed - for example toggling simulation mode. | Failed to change node's mode. |
SDKTransportError: Moving messages in or out of the node failed.
| Factory | Error code | gRPC status | Raise it when | Caller sees by default |
|---|---|---|---|---|
SDKTransportError.data_connection(msg) |
err.sdk.transport.data.connection |
UNAVAILABLE |
Could not establish or keep a data-plane connection. | Failed to connect to the data plane. |
SDKTransportError.data_pubsub(msg) |
err.sdk.transport.data.pubsub |
UNAVAILABLE |
Connected to the data plane, but a publish or subscribe failed. | Failed to publish/subscribe on the data plane. |
SDKTransportError.data_codec(msg) |
err.sdk.transport.data.codec |
INTERNAL |
A data-plane message could not be encoded or decoded. | Failed to encode/decode a data-plane message. |
SDKTransportError.data_not_configured(msg) |
err.sdk.transport.data.not_configured |
FAILED_PRECONDITION |
The data plane was used before it was set up. | Data plane is not configured. |
SDKTransportError.control_connection(msg) |
err.sdk.transport.control.connection |
UNAVAILABLE |
Could not establish or keep a control-plane connection. | Failed to connect to the control plane. |
SDKTransportError.control_pubsub(msg) |
err.sdk.transport.control.pubsub |
UNAVAILABLE |
Connected to the control plane, but a publish or subscribe failed. | Failed to publish/subscribe on the control plane. |
SDKTransportError.control_codec(msg) |
err.sdk.transport.control.codec |
INTERNAL |
A control-plane message could not be encoded or decoded. | Failed to encode/decode a control-plane message. |
SDKTransportError.control_not_configured(msg) |
err.sdk.transport.control.not_configured |
FAILED_PRECONDITION |
The control plane was used before it was set up. | Control plane is not configured. |
SDKServiceError: A service the SDK depends on failed the request.
| Factory | Error code | gRPC status | Raise it when | Caller sees by default |
|---|---|---|---|---|
SDKServiceError.registration(msg) |
err.sdk.service.registration |
UNAVAILABLE |
Registering the node with the Consul discovery service failed. | Failed to register the node with Consul discovery service. |
SDKServiceError.twin(msg) |
err.sdk.service.twin |
UNAVAILABLE |
A request to the digital twin service failed. | Request to digital twin failed. |
SDKServiceError.data_repository(msg) |
err.sdk.service.data_repository |
UNAVAILABLE |
A request to the data repository failed. | Request to data repository failed. |
SDKServiceError.streaming(msg) |
err.sdk.service.streaming |
UNAVAILABLE |
A streaming request failed - for example the LiveKit visualization path. | Streaming request failed. |
SDKOperationError: An SDK-internal operation failed.
| Factory | Error code | gRPC status | Raise it when | Caller sees by default |
|---|---|---|---|---|
SDKOperationError.bootstrap(msg) |
err.sdk.operation.bootstrap |
INTERNAL |
The node bootstrap service could not be started. | Failed to start the node bootstrap service. |
SDKOperationError.status_check(msg) |
err.sdk.operation.status_check |
INTERNAL |
Sending or receiving a node status update failed. | Failed to send/receive node status. |
SDKOperationError.health_check(msg) |
err.sdk.operation.health_check |
INTERNAL |
A health check could not be completed. | Node health check failed. |
SDKOperationError.node_not_found(msg) |
err.sdk.operation.node_not_found |
NOT_FOUND |
The requested node is not in the registry, or is not running. | Requested node is not running or not found. |
SDKConfigError: Configuration handed to the SDK is unusable.
| Factory | Error code | gRPC status | Raise it when | Caller sees by default |
|---|---|---|---|---|
SDKConfigError.missing(msg) |
err.sdk.config.missing |
INVALID_ARGUMENT |
A required configuration key was not supplied. | Required configuration missing. |
SDKConfigError.invalid(msg) |
err.sdk.config.invalid |
INVALID_ARGUMENT |
Configuration parsed, but a value is not acceptable. | Configuration is invalid. |
SDKConfigError.parse(msg) |
err.sdk.config.parse |
INVALID_ARGUMENT |
Configuration could not be parsed at all - malformed YAML, JSON or env value. | Configuration could not be parsed. |
SDKError: Base class for errors raised by the SDK itself.
| Factory | Error code | gRPC status | Raise it when | Caller sees by default |
|---|---|---|---|---|
SDKError.unknown(msg) |
err.sdk.unknown |
INTERNAL |
An SDK failure that fits none of the specific categories. | An unexpected SDK error occurred. |
See also¶
- Architecture: the controller layer and the legacy
NodeSDKErrorfamily the SDK still raises. - Errors: the node-author guide to the vocabulary.