-
Notifications
You must be signed in to change notification settings - Fork 1
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
Cannot get useful information when an error occurs #30
Comments
Previously, we the generated code did not properly take into account the HTTP status of error responses. We would either return *Error::UnknownError (if the response message was set) or a serde error otherwise. With this patch, we map the status codes to the corresponding error variants and skip deserialization if the response body is empty. Fixes: #30
Thanks for the report! Please check if #31 helps in this case. Also, if you know what kind of input triggers the problem, I can add a test case for it. |
Previously, the generated code did not properly take into account the HTTP status of error responses. We would either return *Error::UnknownError (if the response message was set) or a serde error otherwise. With this patch, we map the status codes to the corresponding error variants and skip deserialization if the response body is empty. Fixes: #30
I think I know how to trigger that manually from a command line but let me get back to that and report back. Thanks for your time! 👋 |
Hi @robin-nitrokey, I've tested it on one use case and it looks quite a lot better - instead of serde error we're getting By the way I've noticed that the error message is basically stuffed in the header: As far as I'm concerned we could consider this closed and if I notice it doesn't work in some other place I'm happy to create a new issue. Thanks for your help and time! 👋 |
Thanks for the feedback! Generally, most endpoints return error messages as part of the body in a JSON document. But as this is not part of the OpenAPI spec, the generated error types don’t contain these strings. I’m not sure why there is no error message in the body in this case. My guess is that this is due to the control flow – authorization is handled by a lower level than the NetHSM business logic, and probably that level does not return error messages. |
Thanks for confirming this! I'm planning to handle and save the error message string in the content body so I guess the login failure issue was not such a great use case... Now I need to look for another operation that can fail 🤔 |
I see. Maybe this test case is useful for you – if you call a normal operation on an unprovisioned instance, you should see an error message: Lines 27 to 35 in bd34dbf
To do it properly, you would need to decode |
I think it's called
I'm going through the ticket that was reported by @dvzrv and it seems we've seen the "serde error" only in case of login failure 🤔 The other errors are currently properly packed in an I think it's good to go! I've got one more thing but I'll create a separate ticket for that. Thanks for your help and time! 🙇 |
Yes, the login error triggered that problem specifically because it had no body, so it could not be deserialized into a |
Previously, the generated code did not properly take into account the HTTP status of error responses. We would either return *Error::UnknownError (if the response message was set) or a serde error otherwise. With this patch, we map the status codes to the corresponding error variants and skip deserialization if the response body is empty. Fixes: #30
Hi,
I've observed the following behaviour: when using
nethsm-sdk-rs
and an API error occurs we're not getting real cause but rathererror in serde: EOF while parsing a value at line 1 column 0
.As one practical example is the backup function (although I've seen it in other cases too).
If I'm not mistaken the actual issue is that on an API failure the code wants to deserialize the body of the response (in default_api.rs file: https://github.com/Nitrokey/nethsm-sdk-rs/blob/main/src/apis/default_api.rs#L2509) and the deserialization fails because the request has empty content (
content-length: 0
). (The deserialization in the backup case wants to create aSystemBackupPostError
, looking at the source it's not clear how that would work without correct JSON in the error-case API response https://github.com/Nitrokey/nethsm-sdk-rs/blob/main/src/apis/default_api.rs#L561-L566).It's quite possible I'm holding it wrong somehow so any suggestions are welcome!
(Our internal ticket: https://gitlab.archlinux.org/archlinux/signstar/-/issues/29 CC @dvzrv)
The text was updated successfully, but these errors were encountered: