diff --git a/internal/client/client.go b/internal/client/client.go index 34a4e27..7fd8a61 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -91,19 +91,9 @@ func DialOptsFromFlags(cmd *cobra.Command, token storage.Token) ([]grpc.DialOpti interceptors = append(interceptors, zgrpcutil.CheckServerVersion) } - maxMessageSize := cobrautil.MustGetInt(cmd, "max-message-size") - opts := []grpc.DialOption{ grpc.WithChainUnaryInterceptor(interceptors...), grpc.WithChainStreamInterceptor(zgrpcutil.StreamLogDispatchTrailers), - grpc.WithDefaultCallOptions( - // The default max client message size is 4mb. - // It's conceivable that a sufficiently complex - // schema will easily surpass this, so we set the - // limit higher here. - grpc.MaxCallRecvMsgSize(maxMessageSize), - grpc.MaxCallSendMsgSize(maxMessageSize), - ), } if cobrautil.MustGetBool(cmd, "insecure") || (token.IsInsecure()) { @@ -123,5 +113,17 @@ func DialOptsFromFlags(cmd *cobra.Command, token storage.Token) ([]grpc.DialOpti opts = append(opts, grpc.WithAuthority(hostnameOverride)) } + maxMessageSize := cobrautil.MustGetInt(cmd, "max-message-size") + if maxMessageSize != 0 { + opts = append(opts, grpc.WithDefaultCallOptions( + // The default max client message size is 4mb. + // It's conceivable that a sufficiently complex + // schema will easily surpass this, so we set the + // limit higher here. + grpc.MaxCallRecvMsgSize(maxMessageSize), + grpc.MaxCallSendMsgSize(maxMessageSize), + )) + } + return opts, nil } diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 903332f..17e9239 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -75,7 +75,7 @@ func Run() { rootCmd.PersistentFlags().Bool("no-verify-ca", false, "do not attempt to verify the server's certificate chain and host name") rootCmd.PersistentFlags().Bool("debug", false, "enable debug logging") rootCmd.PersistentFlags().String("request-id", "", "optional id to send along with SpiceDB requests for tracing") - rootCmd.PersistentFlags().Int("max-message-size", 4*1024*1024, "maximum size (bytes) of a gRPC message sent or received by zed") + rootCmd.PersistentFlags().Int("max-message-size", 0, "maximum size (bytes) of a gRPC message that can be sent or received by zed") _ = rootCmd.PersistentFlags().MarkHidden("debug") // This cannot return its error. versionCmd := &cobra.Command{