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

RX 7900 Fixes and refactoring for error reporting #279

Merged
merged 3 commits into from
Mar 3, 2024

Conversation

In-line
Copy link
Contributor

@In-line In-line commented Mar 3, 2024

Hi, Dear @ilya-zlobintsev thank you for amazing peace of open source software!

A few key points about this PR.

  1. .context calls are added almost everywhere to make debugging issues easier
  2. serde-error is added as dependency to produce nicer error backtraces
  3. A weird bug fix for RX 7900 XTX

@In-line
Copy link
Contributor Author

In-line commented Mar 3, 2024

This is how errors look with this PR (last patch reverted for demonstration purposes)

image

Copy link
Owner

@ilya-zlobintsev ilya-zlobintsev left a comment

Choose a reason for hiding this comment

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

Overall, I really like these changes, it should make tracking down issues in bug reports notably easier.

It looks like there's a test that needs to be updated: https://github.com/ilya-zlobintsev/LACT/actions/runs/8131682866/job/22222045972?pr=279

@In-line In-line force-pushed the rx7900-xtx-fixes branch from d438e9a to 9401074 Compare March 3, 2024 18:44
@In-line In-line requested a review from ilya-zlobintsev March 3, 2024 18:45
Comment on lines 37 to 48
let expected_response = json!({
"status": "error",
"data": "my super error"
});
let response = Response::<()>::from(anyhow!("my super error"));

let response = Response::<()>::Error("my super error".to_owned());
let json_value = serde_json::to_value(&response).unwrap();
let parsed_response: Response<()> = serde_json::from_value(json_value).unwrap();

assert_eq!(serde_json::to_value(response).unwrap(), expected_response);
match (response, parsed_response) {
(Response::Error(first), Response::Error(second)) => {
assert_eq!(second.to_string(), first.to_string())
}
_ => unreachable!(),
};
Copy link
Owner

Choose a reason for hiding this comment

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

The goal of these tests is to check the actual json representation of responses, not just that serialization is working properly. So it should still have an expected_response json literal that's compared against the serialized form.
I think here it would be especially useful to check the json representation of an error with a backtrace. If i'm understanding it right, it should be a nested error object.

Copy link
Contributor Author

@In-line In-line Mar 3, 2024

Choose a reason for hiding this comment

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

@ilya-zlobintsev actual JSON representation is implementation defined in the serde-error crate. I think it doesn't matter what actual format is uses. You would need to update test after every serde-error dependency update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What matters is that it produces same output after serialization/de-serialization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how to implement that test properly without hard pinning the dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ilya-zlobintsev do you have any suggestions?

Copy link
Owner

Choose a reason for hiding this comment

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

While the main purpose of the JSON API is communication between the GUI and the daemon, it's not an arbitrary internal API as it's possible to make third party scripts that interact with it. For this reason, I would like to avoid changing the JSON representation of requests/responses when possible. Of course this PR changes the error format, which is fine, but it would be best to avoid accidentally changing it again in the future.

In practice I don't think it's going to be an issue, serde-error didn't have any functional changes in 4 years, but I would still like to have a test that defines what the error representation is.

Copy link
Contributor Author

@In-line In-line Mar 3, 2024

Choose a reason for hiding this comment

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

@ilya-zlobintsev Okay, I pinned the dependency and updated test. I understand your point. Thanks for patience!

@ilya-zlobintsev
Copy link
Owner

The fedora package build error seems to be related to a missing signing key, you can ignore it.

@In-line In-line force-pushed the rx7900-xtx-fixes branch from 9401074 to ed20ca6 Compare March 3, 2024 19:35
@In-line In-line requested a review from ilya-zlobintsev March 3, 2024 19:39
@ilya-zlobintsev ilya-zlobintsev merged commit 5a78c72 into ilya-zlobintsev:master Mar 3, 2024
5 of 17 checks passed
@In-line In-line deleted the rx7900-xtx-fixes branch March 3, 2024 19:51
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.

2 participants