Rename Custom Post Slug using taxonomy

You’re passing 3 arguments to your function ($permalink, $post, $leavename), but you’re only specifying that it has 2 when you’re adding the filter (the last parameter to add_filter). Change your add_filter call to this:

add_filter( 'post_type_link', 'custom_post_type_link', 10, 3 );