langflow-ai/langflow · error · HTTPException
Name conflict — another role already uses this name
Error message
Name conflict — another role already uses this name
What it means
Raised by PATCH /api/v1/authz/roles/{role_id} when session.commit() raises an IntegrityError. The route rolls back and maps any integrity failure to a 409 with this message; in practice it means the new name collides with another role's unique name constraint (a parent_role_id cycle or other constraint violation would surface here too, since the handler is not constraint-specific).
Source
Thrown at src/backend/base/langflow/api/v1/authz_roles.py:235
if "permissions" in fields_set:
# permissions column is nullable=False (default_factory=list). An empty
# list is the natural "clear" — None would violate the constraint at
# commit, so reject it up front.
if payload.permissions is None:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="permissions cannot be null; pass an empty list to clear",
)
role.permissions = list(payload.permissions)
role.updated_at = datetime.now(timezone.utc)
try:
await session.commit()
except IntegrityError as exc:
await session.rollback()
raise HTTPException(
status_code=status.HTTP_409_CONFLICT,
detail="Name conflict — another role already uses this name",
) from exc
await session.refresh(role)
await safe_invalidate_role(get_authorization_service(), role.id, op="role:update")
await audit_decision(
user_id=current_user.id,
action="role:update",
obj=f"role:{role.id}",
result="allow",
details={
"role_name": role.name,
"fields_changed": sorted(fields_set),
},
)
logger.info("Updated role %s (id=%s)", role.name, role.id)
return RoleRead.model_validate(role)
View on GitHub (pinned to 976ec789d2)
Solutions
- Pick a different, unique name for the role
- GET /api/v1/authz/roles first and check the desired name is not taken (note: still racy under concurrency)
- Treat 409 as retryable with a new name — catch it in the client and prompt the user for a different name
- If you were not renaming, inspect the server log for the underlying IntegrityError (parent_role_id cycle, etc.)
Example fix
// before
await updateRole(id, { name: 'admin' }); // another role already called 'admin'
// after
const roles = await listRoles();
const name = roles.some(r => r.name === 'admin') ? 'admin-2' : 'admin';
await updateRole(id, { name }); Defensive patterns
Strategy: try-catch
Validate before calling
async function isRoleNameFree(name: string) {
const roles = await (await fetch('/api/v1/authz/roles')).json();
return !roles.some(r => r.name === name);
} Try / catch
try {
await patchRole(id, body);
} catch (e) {
if (e instanceof HttpException && e.status === 409) {
// prompt user for a new name; do not blind-retry the same name
} else throw e;
} Prevention
- Check name availability before the PATCH, but still handle 409 (the check is racy)
- Suggest auto-suffixed names (-2, -3) when a 409 hits a user-typed name
When it happens
Trigger: PATCH /authz/roles/{id} renaming a role to a name already used by another role; creating a parent_role_id cycle that the DB rejects at commit.
Common situations: Case-sensitive vs case-insensitive unique indexes surprising callers ("Admin" vs "admin"); renaming during concurrent role administration where another request claimed the name between your GET and PATCH; seeding scripts that rename built-in roles to colliding names.
Related errors
- Role still has active assignments — revoke them before delet
- Share could not be created: it may already exist or conflict
- Role with name {payload.name!r} already exists
- name cannot be null
- permissions cannot be null; pass an empty list to clear
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/2e7dc0e0e4979454.
Report an issue: GitHub.