Skip to content

Commit

Permalink
Merge pull request #1807 from authzed/do-not-break-debug-info-in-zed
Browse files Browse the repository at this point in the history
do not return backward incompatible `--explain` debug info in trailer
  • Loading branch information
vroldanbet committed Mar 18, 2024
2 parents d35b109 + bd47185 commit 32e903f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
3 changes: 2 additions & 1 deletion internal/services/v1/debug_test.go
Expand Up @@ -482,7 +482,8 @@ func TestCheckPermissionWithDebug(t *testing.T) {
encodedDebugInfo, err := responsemeta.GetResponseTrailerMetadataOrNil(trailer, responsemeta.DebugInformation)
req.NoError(err)

req.NotNil(encodedDebugInfo)
// DebugInfo No longer comes as part of the trailer
req.Nil(encodedDebugInfo)

debugInfo := checkResp.DebugTrace
req.NotEmpty(debugInfo.SchemaUsed)
Expand Down
9 changes: 0 additions & 9 deletions internal/services/v1/permissions.go
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/authzed/authzed-go/pkg/requestmeta"
"github.com/authzed/authzed-go/pkg/responsemeta"
v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
"github.com/jzelinskie/stringz"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -106,14 +105,6 @@ func (ps *permissionServer) CheckPermission(ctx context.Context, req *v1.CheckPe
return nil, ps.rewriteError(ctx, cerr)
}
debugTrace = converted

// TODO(jschorr): Remove this once the trailer is not longer used by anyone.
serr := responsemeta.SetResponseTrailerMetadata(ctx, map[responsemeta.ResponseMetadataTrailerKey]string{
responsemeta.DebugInformation: `{"note": "debug information has been moved into the response object. See https://spicedb.dev/d/check-traces"}`,
})
if serr != nil {
return nil, ps.rewriteError(ctx, serr)
}
}

if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions internal/services/v1/permissions_test.go
Expand Up @@ -293,7 +293,7 @@ func TestCheckPermissions(t *testing.T) {
require.NoError(err)

if debug {
require.NotNil(encodedDebugInfo)
require.Nil(encodedDebugInfo)

debugInfo := checkResp.DebugTrace
require.NotNil(debugInfo.Check)
Expand Down Expand Up @@ -342,7 +342,8 @@ func TestCheckPermissionWithDebugInfo(t *testing.T) {
encodedDebugInfo, err := responsemeta.GetResponseTrailerMetadataOrNil(trailer, responsemeta.DebugInformation)
require.NoError(err)

require.NotNil(encodedDebugInfo)
// debug info is returned empty to make sure clients are not broken with backward incompatible payloads
require.Nil(encodedDebugInfo)

debugInfo := checkResp.DebugTrace
require.GreaterOrEqual(len(debugInfo.Check.GetSubProblems().Traces), 1)
Expand Down

0 comments on commit 32e903f

Please sign in to comment.