oso icon indicating copy to clipboard operation
oso copied to clipboard

Improves error reporting

Open xfbs opened this issue 2 years ago • 2 comments

Hey! We ran into an issue where we got an error from Oso. It looked like this:

Type error: Expected Instance

We've added this little hot patch here so that we get a more useful error message:

Type error: Expected Instance of service::auth::resources::Resource got String

The offending code was that we were using the wrong type in one place:

has_role(actor: User, “member”, resource: Resource) if
  # bug: this should have been is_member_of(resource) instead
  actor.is_member_of(resource.id);

But this was really hard to track down in a large Polar file with the previous error message.

In the future, we would maybe improve it to add some more context to the errors, such as line numbers. This would greatly improve the debugging experience.

Maybe look over the PR before merging it because I put it together quickly for debugging.

xfbs avatar May 02 '23 10:05 xfbs

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

github-actions[bot] avatar May 02 '23 10:05 github-actions[bot]

I have read the CLA Document and I hereby sign the CLA

alisomay avatar May 02 '23 13:05 alisomay