Skip to content

chore: add documentation of LR debugging#547

Open
tstirrat15 wants to merge 2 commits intomainfrom
tstirrat/lr-cyclic-relationship-debug
Open

chore: add documentation of LR debugging#547
tstirrat15 wants to merge 2 commits intomainfrom
tstirrat/lr-cyclic-relationship-debug

Conversation

@tstirrat15
Copy link
Copy Markdown
Collaborator

Description

The documentation component of authzed/spicedb#3070. This adds instructions on how to read and interpret the output.

Changes

  • Add documentation

Testing

Review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

Preview deployment status for this pull request.

Name Status Preview Updated (UTC)
docs 🟢 Ready Visit Preview Apr 29, 2026 07:05pm


Note that the `parent` relation on the `folder` definition is recursive, and that we've written a `parent` relationship from `folder:a` to `folder:b` and vice versa, creating a cycle.

If you run `zed import` on this file, and then run `zed permission lookup-resources lookup-resources resource view user:someuser`, you'll get a `max depth exceeded` error.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
If you run `zed import` on this file, and then run `zed permission lookup-resources lookup-resources resource view user:someuser`, you'll get a `max depth exceeded` error.
If you run `zed import` on this file, and then run `zed permission lookup-resources resource view user:someuser`, you'll get a `max depth exceeded` error.

Comment on lines +26 to 28
SpiceDB supports tracing of check requests to view the path(s) taken to compute the result, as well as timing information.

While it is recommended that SpiceDB schema be validated and tested before production deployment, there are many scenarios where being able to see the actual paths taken against production data is incredibly important.
Copy link
Copy Markdown
Contributor

@miparnisari miparnisari Apr 29, 2026

Choose a reason for hiding this comment

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

Suggested change
SpiceDB supports tracing of check requests to view the path(s) taken to compute the result, as well as timing information.
While it is recommended that SpiceDB schema be validated and tested before production deployment, there are many scenarios where being able to see the actual paths taken against production data is incredibly important.
Sometimes you may need to see exactly which relationship paths led to a result in a CheckPermission query. To this end, the [CheckPermission](https://buf.build/authzed/api/docs/main%3Aauthzed.api.v1#authzed.api.v1.CheckPermissionRequest) API supports adding a boolean `withTracing` request parameter.

</Callout>

Configuring this header is done by setting the header `io.spicedb.requestdebuginfo` to the string `true`.
Configuring this header is done by setting the `with_tracing` field on the [CheckDebugRequest](https://buf.build/authzed/api/docs/main%3Aauthzed.api.v1#authzed.api.v1.CheckPermissionRequest) to `true`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Configuring this header is done by setting the `with_tracing` field on the [CheckDebugRequest](https://buf.build/authzed/api/docs/main%3Aauthzed.api.v1#authzed.api.v1.CheckPermissionRequest) to `true`.

information will be found in the response footer as JSON.
</Callout>

## Zed
Copy link
Copy Markdown
Contributor

@miparnisari miparnisari Apr 29, 2026

Choose a reason for hiding this comment

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

similar to the "explain flag" section:

image

can you add a "debug flag" section for LR?

also, in "explain flag", can you get rid of the "tracing header" sentence? i feel like it adds no value, the section is self-explanatory


- The lines should be read as resources with the relation connecting them to the previous pair. For example, in the line marked by `(cycle)` can be read eas "there's a `view` relation between `folder:a` and `folder:b`."
- The relation can a schema relation, a schema permission, or a schema subject relation. Notice that in the line marked by `cycle`, the relation is `view`, corresponding to the `view` permission on the `folder` definition in the schema. This means that you might need to do some translation to connect the relation in a line to a concrete relationship.
- The `(cycle)` marks the endpoints where a resource that is a member of a cycle was seen for the second time. It does _not_ mean that the marked relation is the offending relation, just that everything between the marks is a member of the cycle. You'll need to think about which relationships are written where to understand what needs to change in your business logic to avoid the cycle.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the other two bullets feel useless to me; i'd get rid of them. the third is the bullet that is important.

Comment on lines +238 to +251
You'll get output that looks like this:

```
The following resource/relation pairs were found in a cycle in LookupResources:

- folder:a#view

To further debug this, issue a check from the resource to itself across the relation.
For example, with the identified pair `resource:foo#view`, you would make the following call:

zed permission check resource:foo view resource:foo --explain

For more information, see the LookupResources section under https://spicedb.dev/d/debug-max-depth
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i feel iffy about pasting the literal error here, which can change in the future. why not just say "use --debug which will give you more information"?

and the following paragraphs are more about zed permission check --explain than about LR 😅

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