Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Response error code data model #1290

Merged
merged 3 commits into from
Mar 20, 2024

Conversation

slinkydeveloper
Copy link
Contributor

Previously the response error codes were related to gRPC status codes. From now on, we allow any HTTP status code as output. Fix #1231

From now on the code of the invocation error can be any HTTP status code. We also define some constant error codes, we use throughout the code.
Copy link
Contributor

@igalshilman igalshilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @slinkydeveloper,
looks good to me, this is mostly renaming.
I have one question about casting the error code into u16 maybe worth to double check what is the behavior if the value is greater than u16::MAX.
Since this is a user supplied value without sensitization.

@@ -82,7 +82,7 @@ impl HandlerError {
HandlerError::BadAwakeablesPath => StatusCode::BAD_REQUEST,
HandlerError::NotImplemented => StatusCode::NOT_IMPLEMENTED,
HandlerError::Invocation(e) => {
invocation_status_code_to_http_status_code(e.code().into())
StatusCode::from_u16(e.code().into()).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slinkydeveloper what happens here if the integer value does not fit into u16?
would that be a value truncation or a runtime panic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case there is no downcasting from u32 to u16, as that e.code.into() will simply unwrap this value https://github.com/restatedev/restate/pull/1290/files#diff-9ce8c7545122d14206df42ac7114b35be108a998c5a1ae112166d1837a6a93ffR19

In other places we perform the conversion u32 -> u16, where in case it doesn't fit, we replace it with 500: https://github.com/restatedev/restate/pull/1290/files#diff-9ce8c7545122d14206df42ac7114b35be108a998c5a1ae112166d1837a6a93ffR45-R52

@slinkydeveloper slinkydeveloper merged commit 86af180 into restatedev:main Mar 20, 2024
4 of 5 checks passed
@slinkydeveloper slinkydeveloper deleted the issues/1231 branch March 20, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Response error data model
2 participants