The database constraints don't match the constraint in the Python code.
The Python code uses our standard valid_name() constraint of ^[a-z0-9][a-z0-9\+\.\-]*$
The database constraint uses a valid_branch_name() constraint of ^(?i)[a-z0-9][a-z0-9+\.\-@_]+$ (i.e. same as above but allows upper case, "@" and "_").
The database constraints don't match the constraint in the Python code.
The Python code uses our standard valid_name() constraint of ^[a-z0- 9][a-z0- 9\+\.\- ]*$
The database constraint uses a valid_branch_name() constraint of ^(?i)[a- z0-9][a- z0-9+\. \-@_]+$ (i.e. same as above but allows upper case, "@" and "_").
One of these constraints is incorrect.