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

Implement structured errors for all user facing errors #858

Merged
merged 1 commit into from
Oct 6, 2022

Conversation

josephschorr
Copy link
Member

Fixes #816

@josephschorr josephschorr requested review from jzelinskie and a team September 30, 2022 22:12
@github-actions github-actions bot added area/api v1 Affects the v1 API area/dependencies Affects dependencies area/dispatch Affects dispatching of requests area/schema Affects the Schema Language area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Sep 30, 2022
@josephschorr josephschorr force-pushed the structured-errors branch 2 times, most recently from 036b6c2 to 3c4dac9 Compare September 30, 2022 22:15
Copy link
Member

@jzelinskie jzelinskie left a comment

Choose a reason for hiding this comment

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

For the most part, no major issues. I had some organizational questions, too, though.

internal/dispatch/graph/errors.go Outdated Show resolved Hide resolved
internal/dispatch/graph/errors.go Outdated Show resolved Hide resolved
internal/namespace/errors.go Show resolved Hide resolved
pkg/errors/common.go Outdated Show resolved Hide resolved
pkg/errors/withstatus.go Outdated Show resolved Hide resolved
pkg/errors/withstatus.go Outdated Show resolved Hide resolved
pkg/errors/testutil.go Outdated Show resolved Hide resolved
"github.com/authzed/spicedb/pkg/schemadsl/compiler"
)

func rewriteError(ctx context.Context, err error) error {
Copy link
Member

Choose a reason for hiding this comment

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

If everything implements the proper interface for producing metadata, I wonder if it's better to be explicit at the call-sites as to how we're converting. That way we can distinguish when two different calls can return the same error, but have different desired responses.

Copy link
Member Author

Choose a reason for hiding this comment

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

rewriteError is per package, so it shouldn't need to be differentiated (yet anyway)

Copy link
Member

@jzelinskie jzelinskie Oct 6, 2022

Choose a reason for hiding this comment

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

The only issue I see with this approach is it'll cause developers to just thoughtlessly do rewriteError(ctx, err) and not think about what actually needs to happen. We've been doing it up until now, so I think it's fine, but I definitely think this pattern promotes a lack of thought for properly handling errors.

@josephschorr josephschorr force-pushed the structured-errors branch 2 times, most recently from a4dbe2d to e1b1a1d Compare October 4, 2022 16:08
@josephschorr
Copy link
Member Author

Updated

@josephschorr josephschorr merged commit d18bd64 into authzed:main Oct 6, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 6, 2022
@josephschorr josephschorr deleted the structured-errors branch October 6, 2022 16:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/api v1 Affects the v1 API area/dependencies Affects dependencies area/dispatch Affects dispatching of requests area/schema Affects the Schema Language area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Machine readable precondition failure information
2 participants