It’s not that your animation names are null, it’s your anim variable that is null.
Make sure that this reference you are assigning to this variable is correct.
@onready var anim: AnimationPlayer = $AnimationPlayer
As @wchc said, the variable may be null due to a reference problem, meaning that the code is looking for something in the wrong place therefore it assigns null since it didn’t find anything.
I can also think of another possibility, which is a timing issue. when this node is ready the node you are trying to reference it is still not ready and so the variable is assigned to null.
If you are not able to solve this, share your node structure.