Skip to content

Commit

Permalink
Map out_of_range to invalid_argument error
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeling committed Oct 28, 2024
1 parent fd92048 commit d16e7d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions databroker/src/grpc/kuksa_val_v2/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl broker::UpdateError {
format!("Wrong type provided (id: {})", id),
),
broker::UpdateError::OutOfBounds => tonic::Status::new(
tonic::Code::OutOfRange,
tonic::Code::InvalidArgument,
format!("Value out of bounds (id: {})", id),
),
broker::UpdateError::UnsupportedType => tonic::Status::new(
Expand Down Expand Up @@ -610,7 +610,7 @@ impl broker::ActuationError {
match self {
broker::ActuationError::NotFound => tonic::Status::not_found(message),
broker::ActuationError::WrongType => tonic::Status::invalid_argument(message),
broker::ActuationError::OutOfBounds => tonic::Status::out_of_range(message),
broker::ActuationError::OutOfBounds => tonic::Status::invalid_argument(message),
broker::ActuationError::UnsupportedType => tonic::Status::invalid_argument(message),
broker::ActuationError::PermissionDenied => tonic::Status::permission_denied(message),
broker::ActuationError::PermissionExpired => tonic::Status::unauthenticated(message),
Expand Down
10 changes: 5 additions & 5 deletions databroker/src/grpc/kuksa_val_v2/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,13 @@ impl proto::val_server::Val for broker::DataBroker {
// PERMISSION_DENIED if access is denied for the actuator.
// UNAUTHENTICATED if no credentials provided or credentials has expired
// UNAVAILABLE if there is no provider currently providing the actuator
// OUT_OF_RANGE if the provided value is out of the min/max range specified
// DATA_LOSS is there is a internal TransmissionFailure
// INVALID_ARGUMENT
// - if the data type used in the request does not match
// the data type of the addressed signal
// - if the requested value is not accepted,
// e.g. if sending an unsupported enum value
// - if the provided value is out of the min/max range specified
//
async fn actuate(
&self,
Expand Down Expand Up @@ -402,13 +402,13 @@ impl proto::val_server::Val for broker::DataBroker {
// PERMISSION_DENIED if access is denied for any of the actuators.
// UNAUTHENTICATED if no credentials provided or credentials has expired
// UNAVAILABLE if there is no provider currently providing an actuator
// OUT_OF_RANGE if any of the provided actuators values are out of the min/max range specified
// DATA_LOSS is there is a internal TransmissionFailure
// INVALID_ARGUMENT
// - if the data type used in the request does not match
// the data type of the addressed signal
// - if the requested value is not accepted,
// e.g. if sending an unsupported enum value
// - if any of the provided actuators values are out of the min/max range specified
//
async fn batch_actuate(
&self,
Expand Down Expand Up @@ -514,12 +514,12 @@ impl proto::val_server::Val for broker::DataBroker {
// PERMISSION_DENIED
// - if access is denied for any of the signals.
// UNAUTHENTICATED if no credentials provided or credentials has expired
// OUT_OF_RANGE if the published value is out of the min/max range specified
// INVALID_ARGUMENT
// - if the data type used in the request does not match
// the data type of the addressed signal
// - if the published value is not accepted,
// e.g. if sending an unsupported enum value
// - if the published value is out of the min/max range specified
//
async fn publish_value(
&self,
Expand Down Expand Up @@ -592,12 +592,12 @@ impl proto::val_server::Val for broker::DataBroker {
// NOT_FOUND if a signal is non-existant.
// PERMISSION_DENIED
// - if access is denied for a signal.
// OUT_OF_RANGE if the published value is out of the min/max range specified
// INVALID_ARGUMENT
// - if the data type used in the request does not match
// the data type of the addressed signal
// - if the published value is not accepted,
// e.g. if sending an unsupported enum value
// - if the published value is out of the min/max range specified
//
// - Provider returns BatchActuateStreamResponse <- Databroker sends BatchActuateStreamRequest
// No error definition, a BatchActuateStreamResponse is expected from provider.
Expand Down Expand Up @@ -1710,7 +1710,7 @@ mod tests {
}
Err(status) => {
// Handle the error from the publish_value function
assert_eq!(status.code(), tonic::Code::OutOfRange);
assert_eq!(status.code(), tonic::Code::InvalidArgument);
// As of the today the first added datapoint get value 0 by default.
assert_eq!(status.message(), "Value out of bounds (id: 0)");
}
Expand Down
8 changes: 4 additions & 4 deletions proto/kuksa/val/v2/val.proto
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ service VAL {
// PERMISSION_DENIED if access is denied for the actuator.
// UNAUTHENTICATED if no credentials provided or credentials has expired
// UNAVAILABLE if there is no provider currently providing the actuator
// OUT_OF_RANGE if the provided value is out of the min/max range specified
// DATA_LOSS is there is a internal TransmissionFailure
// INVALID_ARGUMENT
// - if the data type used in the request does not match
// the data type of the addressed signal
// - if the requested value is not accepted,
// e.g. if sending an unsupported enum value
// - if the provided value is out of the min/max range specified
//
rpc Actuate(ActuateRequest) returns (ActuateResponse);

Expand All @@ -94,13 +94,13 @@ service VAL {
// PERMISSION_DENIED if access is denied for any of the actuators.
// UNAUTHENTICATED if no credentials provided or credentials has expired
// UNAVAILABLE if there is no provider currently providing an actuator
// OUT_OF_RANGE if any of the provided actuators values are out of the min/max range specified
// DATA_LOSS is there is a internal TransmissionFailure
// INVALID_ARGUMENT
// - if the data type used in the request does not match
// the data type of the addressed signal
// - if the requested value is not accepted,
// e.g. if sending an unsupported enum value
// - if any of the provided actuators values are out of the min/max range specified
//
rpc BatchActuate(BatchActuateRequest) returns (BatchActuateResponse);

Expand All @@ -120,12 +120,12 @@ service VAL {
// PERMISSION_DENIED
// - if access is denied for any of the signals.
// UNAUTHENTICATED if no credentials provided or credentials has expired
// OUT_OF_RANGE if the published value is out of the min/max range specified
// INVALID_ARGUMENT
// - if the data type used in the request does not match
// the data type of the addressed signal
// - if the published value is not accepted,
// e.g. if sending an unsupported enum value
// - if the published value is out of the min/max range specified
//
rpc PublishValue(PublishValueRequest) returns (PublishValueResponse);

Expand All @@ -150,12 +150,12 @@ service VAL {
// NOT_FOUND if a signal is non-existant.
// PERMISSION_DENIED
// - if access is denied for a signal.
// OUT_OF_RANGE if the published value is out of the min/max range specified
// INVALID_ARGUMENT
// - if the data type used in the request does not match
// the data type of the addressed signal
// - if the published value is not accepted,
// e.g. if sending an unsupported enum value
// - if the published value is out of the min/max range specified
//
// - Provider returns BatchActuateStreamResponse <- Databroker sends BatchActuateStreamRequest
// No error definition, a BatchActuateStreamResponse is expected from provider.
Expand Down

0 comments on commit d16e7d5

Please sign in to comment.