remove node links by python
If there are no links you will get indexerror, so I would rewrite your last three strings of code:

for mat in bpy.data.materials:
    mat_node = mat.node_tree.nodes
    for node in mat_node:
        if node.name == "Principled BSDF":
            for link in node.inputs[0].links:
                mat.node_tree.links.remove(link)