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

feat: add failure reason to events #4203

Merged
merged 4 commits into from
Nov 14, 2024
Merged

Conversation

zepatrik
Copy link
Member

Not sure if this covers all the error types we can get, but it should be the majority. We can still add more once we stumble upon them.

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.50%. Comparing base (a90df58) to head (62ccfb2).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4203   +/-   ##
=======================================
  Coverage   78.49%   78.50%           
=======================================
  Files         380      380           
  Lines       27143    27172   +29     
=======================================
+ Hits        21306    21331   +25     
- Misses       4216     4218    +2     
- Partials     1621     1623    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 375 to 383
func reasonForError(err error) string {
if ve := new(schema.ValidationError); errors.As(err, &ve) {
return ve.Message
}
if r := *new(herodot.ReasonCarrier); errors.As(err, &r) {
return r.Reason()
}
return fmt.Sprintf("reason could not be determined for error: %T", err)
}
Copy link
Member

Choose a reason for hiding this comment

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

People will ask about "reason IDs" to find e.g. all failed logins for reason X over time. Don't our validation errors have some type of ID or error code that we could emit?

Copy link
Member

Choose a reason for hiding this comment

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

I want to avoid people relying on these errors and then we change the casing or error message and we get complaints about backwards incompatible changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree here. We might be able to reuse the text package message IDs, although we might need to add a few more there as not all errors have a message associated.
Should we then split it into two attributes, ReasonID and Reason?

Copy link
Member

Choose a reason for hiding this comment

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

Yes please

Copy link
Member

Choose a reason for hiding this comment

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

We can also set some default like "contact_support" or something for the reason id to make it clear that you should request a reason id if it doesn't exist (opposed to reading the reason string field)

@zepatrik zepatrik merged commit afa7618 into master Nov 14, 2024
29 checks passed
@zepatrik zepatrik deleted the feat/event-failure-reason branch November 14, 2024 12:37
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