Change this to
msh.topology.create_connectivity(msh.topology.dim-1, msh.topology.dim) dofs = fem.locate_dofs_topological((V), msh.topology.dim-1, ft.find(2))
Please see several other topics for the exact same error: