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

attestation-service: Refactor errors in attestation module #327

Conversation

kartikjoshi21
Copy link
Contributor

Replace anyhow error crate with thiserror crate
Fixes: #231

@kartikjoshi21 kartikjoshi21 force-pushed the kartikjoshi21/refactor-att-svc-error branch from 75c19bd to 693500c Compare February 22, 2024 10:46
Copy link
Contributor

@mkulke mkulke left a comment

Choose a reason for hiding this comment

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

a couple of smaller remarks, but we're getting there

@kartikjoshi21 kartikjoshi21 force-pushed the kartikjoshi21/refactor-att-svc-error branch 3 times, most recently from 6c47bef to 57e7d2e Compare February 26, 2024 17:29
Copy link
Contributor

@mkulke mkulke left a comment

Choose a reason for hiding this comment

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

almost there, I think we need to keep the error messages specific when we refactor from anyhow! or .context(). pasted some examples in the recent comments to show how this can be achieved.

@kartikjoshi21 kartikjoshi21 force-pushed the kartikjoshi21/refactor-att-svc-error branch 2 times, most recently from be0d242 to 4a8f6b3 Compare March 11, 2024 09:58
@kartikjoshi21 kartikjoshi21 requested a review from mkulke March 11, 2024 09:59
@kartikjoshi21
Copy link
Contributor Author

kartikjoshi21 commented Mar 11, 2024

almost there, I think we need to keep the error messages specific when we refactor from anyhow! or .context(). pasted some examples in the recent comments to show how this can be achieved.

Updated the PR to include the context. Thanks @mkulke @Xynnn007

@kartikjoshi21 kartikjoshi21 force-pushed the kartikjoshi21/refactor-att-svc-error branch from 4a8f6b3 to 7fb301b Compare March 12, 2024 09:09
Copy link
Contributor

@mkulke mkulke left a comment

Choose a reason for hiding this comment

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

looks good, small nits from my side. @Xynnn007 comments should are left to be addressed, mostly adding {0} to extend the error message, where appropriate.

@kartikjoshi21 kartikjoshi21 force-pushed the kartikjoshi21/refactor-att-svc-error branch from 7fb301b to 223a62d Compare March 12, 2024 10:58
@kartikjoshi21 kartikjoshi21 force-pushed the kartikjoshi21/refactor-att-svc-error branch from 223a62d to 3fdc977 Compare March 12, 2024 11:06
Fixes: confidential-containers#231
Signed-off-by: Kartik Joshi <kartikjoshi@microsoft.com>
@kartikjoshi21 kartikjoshi21 force-pushed the kartikjoshi21/refactor-att-svc-error branch from 3fdc977 to 698ddc3 Compare March 20, 2024 09:51
Copy link
Contributor

@mkulke mkulke left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for accommodating the comments

Copy link
Member

@fitzthum fitzthum left a comment

Choose a reason for hiding this comment

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

Looks pretty good.

My only question is about how you chose the names for error enums. It seems like you are creating an enum for each file, but this might not be optimal. For instance we end up with the same errors in multiple enums (like the config error). It also means that the names of the enums aren't super meaningful. The RestfulError enum contains a bunch of stuff that isn't realy related to Rest but is just part of that file. ServiceError is a really general term.

I wonder if there is a way to break up the errors into different logical groups, e.g. ConfigError, ProtocolError, CryptoError, and then share these enums between files.

I guess this isn't too big of a deal, though. If @Xynnn007 and @mkulke are happy with the PR then we can go ahead as is.

@mkulke
Copy link
Contributor

mkulke commented Mar 20, 2024

Looks pretty good.

My only question is about how you chose the names for error enums. It seems like you are creating an enum for each file, but this might not be optimal. For instance we end up with the same errors in multiple enums (like the config error). It also means that the names of the enums aren't super meaningful. The RestfulError enum contains a bunch of stuff that isn't realy related to Rest but is just part of that file. ServiceError is a really general term.

I wonder if there is a way to break up the errors into different logical groups, e.g. ConfigError, ProtocolError, CryptoError, and then share these enums between files.

ah indeed, in some of those cases a per-file error doesn't make much sense, I agree. e.g. in the case of RestfulError & GrpcError, maybe they could be split into ProtocolError and ,idk, "ServiceError"?

Copy link
Member

@Xynnn007 Xynnn007 left a comment

Choose a reason for hiding this comment

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

@jialez0 jialez0 merged commit 7a74faa into confidential-containers:main Apr 10, 2024
16 checks passed
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.

Attestation-Service: replacing anyhow with explicit error types
5 participants