-
Notifications
You must be signed in to change notification settings - Fork 62
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
feat: refactor error message format #1675
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
binbin-li
requested review from
akashsinghal,
jimmyraywv,
luisdlp,
susanshi and
toddysm
as code owners
July 31, 2024 08:28
binbin-li
force-pushed
the
error-log-message
branch
3 times, most recently
from
July 31, 2024 14:12
52d1954
to
a2aa5f6
Compare
Codecov ReportAttention: Patch coverage is
|
binbin-li
force-pushed
the
error-log-message
branch
from
August 1, 2024 04:42
a2aa5f6
to
dda2571
Compare
binbin-li
force-pushed
the
error-log-message
branch
3 times, most recently
from
August 1, 2024 07:09
6d61b27
to
34081c4
Compare
12 tasks
binbin-li
force-pushed
the
error-log-message
branch
from
August 2, 2024 14:06
34081c4
to
65eb936
Compare
susanshi
reviewed
Aug 5, 2024
binbin-li
force-pushed
the
error-log-message
branch
from
August 5, 2024 07:00
65eb936
to
999f5ef
Compare
binbin-li
force-pushed
the
error-log-message
branch
from
August 5, 2024 07:19
999f5ef
to
af1a0d8
Compare
susanshi
approved these changes
Aug 9, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. thanks Binbin
12 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
What this PR does / why we need it:
This PR will refactor the message format returned by Error(). The new format is following the proposed improvement from #1662
Note: this pr is based on #1671, please check the actual diff at: binbin-li#209
In general, for a nested Ratify error, we'll return a message in format:
<Error Code>: <Error Description>: <Error Reason>: <Remediation>
,where
Error Code
is the error code of the root error,Error Description
is concatenated details of all nested errors,Error Reason
is the detail or original error of the root error,and
Remediation
is the remediation of the root error.Let's take the below nested error as example:
Then the
Error()
method should return a string:ROOT_ERR_CODE: top error detail: root error detail: http request failed with 401: root error remediation
.GetDetail()
should return string:top error detail: root error detail
.GetErrorReason()
should return string:http request failed with 401
.GetRemeidation()
should return string:root error remediation
.Therefore, we would stop printing all fields from the Error. In this PR, we keep all existing fields under Error struct. And if the new error format looks good in the following releases, we'll start remove those unused fields gradually.
Examples:
Error log before change:
time=2024-07-31T14:04:45.027923414Z level=error msg=Original Error: (Original Error: (Original Error: (json: cannot unmarshal number into Go struct field azureWIAuthProviderConf.clientID of type string), Error: config invalid, Code: CONFIG_INVALID, Component Type: authProvider, Detail: failed to parse auth provider configuration), Error: auth denied, Code: AUTH_DENIED, Component Type: authProvider), Error: plugin init failure, Code: PLUGIN_INIT_FAILURE, Component Type: referrerStore, Detail: failed to create auth provider from configuration
time=2024-07-31T14:02:52.767626288Z level=error msg=Original Error: (failed to find plugin "notation22" in paths [/.ratify/plugins]), Error: plugin not found, Code: PLUGIN_NOT_FOUND, Component Type: verifier, Detail: plugin not found
Error log after change:
time=2024-07-31T13:48:09.976909601Z level=error msg=CONFIG_INVALID: failed to create auth provider from configuration: failed to parse auth provider configuration: json: cannot unmarshal number into Go struct field azureWIAuthProviderConf.clientID of type string
time=2024-07-31T13:57:55.837222446Z level=error msg=PLUGIN_NOT_FOUND: plugin not found: failed to find plugin "notation22" in paths [/.ratify/plugins]
Which issue(s) this PR fixes (optional, using
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when the PR gets merged):Fixes: #1655
Type of change
Please delete options that are not relevant.
main
branch)How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration
Checklist:
Post Merge Requirements
Helm Chart Change