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

✨ Use structured errors #439

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

czunker
Copy link
Contributor

@czunker czunker commented Mar 14, 2023

No description provided.

Signed-off-by: Christian Zunker <[email protected]>
@czunker
Copy link
Contributor Author

czunker commented Mar 14, 2023

This uses the structured errors from mondoohq/cnquery#924. It is a follow-up to #424

if r.data.Errors[assetsByPlatform[platform][i].Mrn] != nil {
es := r.data.Errors[assetsByPlatform[platform][i].Mrn]
ei := errdetails.ErrorInfo{}
pberr := anypb.UnmarshalTo(es.Details[0], &ei, proto.UnmarshalOptions{})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The explorer ErrorStatusCode is buried in the details, so I have to unpack it here.

if len(executionJob.Queries) == 0 {
// send a proto error with details, so that the agent can render it properly
msg := "resolved policy does not contain any queries"
st := status.New(codes.NotFound, msg)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we could use the explorer.NoQueries code here, that would make other parts of the code easier.

I'm not sure whether I missed something here or it just isn't possible. I didn't manage to replace the code.

@czunker czunker requested a review from chris-rock March 14, 2023 09:18
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.

1 participant