It is quite likely that you have tagged the wrong surfaces.
Please make sure that you only include the code of generating the mesh + reading it in, and ensure that the failure lies in the line:
and not any other line of your code.
See for instance: Adding 1d physical groups to gmsh model causes errors when convert it to dolfinx mesh - #2 by dokken