Resolvers
Surface and handle failed feature values.
Resolvers can raise errors in the course of executing, and handle errors in resolving other feature values.
If your resolver fails by raising an exception,
the error will be surfaced as a
ChalkError
in query responses.
Clients will receive a null
value for the feature,
and by default,
downstream resolvers won’t run.
By default, if there was an error in computing one of the inputs to a resolver, that resolver will also fail with the error code UPSTREAM_FAILED. To handle failures in the input features, take as input the feature value, but wrapped in typing.Optional:
from typing import Optional
@online
def fn(score: Optional[User.fraud_score]) -> ...:
The argument score
will receive the value None
in the case of a failure.
If you’d like to provide a default value to use in the case of a failure, you can use Python’s syntax for assigning a default value to an argument:
@online
def fn(score: Optional[User.fraud_score] = -1) -> ...: