Too few arguments sent to custom function

Your function needs 2 arguments, but you didn’t mention this to add_action

add_action( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )

https://developer.wordpress.org/reference/functions/add_action/

By only passing the tag and function to add, PHP used the defaults for priority and accepted arguments, which were a priority of 10, and 1 accepted argument. But 1 != 2.

So, to fix this, you need to specify the accepted arguments parameter