langflow-ai/langflow · error · HTTPException
name cannot be null
Error message
name cannot be null
What it means
Raised by PATCH /api/v1/authz/roles/{role_id} when the request body explicitly sets "name" to null. The authz_role.name column is NOT NULL and unique on the database side, so the route rejects the null at the API boundary (400) instead of letting the commit fail with an IntegrityError that the catch block would mislabel as a name conflict (409). Only fields present in the request's fields_set are validated, so omitting "name" entirely is safe.
Source
Thrown at src/backend/base/langflow/api/v1/authz_roles.py:212
detail="parent_role_id does not reference an existing role",
)
if await _detect_parent_cycle(session, role_id=role.id, proposed_parent_id=payload.parent_role_id):
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Setting this parent would create a role hierarchy cycle",
)
role.parent_role_id = payload.parent_role_id
if "description" in fields_set:
# description is nullable on the DB side — None is a legitimate clear.
role.description = payload.description
if "name" in fields_set:
# name is NOT NULL + unique on the DB side; reject an explicit null at
# the boundary so the caller gets a clear 400 instead of an opaque
# IntegrityError that the catch block below mislabels as "Name conflict".
if payload.name is None:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="name cannot be null",
)
role.name = payload.name
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)
View on GitHub (pinned to 976ec789d2)
Solutions
- Remove the "name" key from the PATCH body entirely when you do not intend to rename the role
- Send a non-empty string: {"name": "new-role-name"}
- If using Pydantic on the client, serialize with model_dump(exclude_unset=True) or exclude_none=True so unset fields are omitted
- If clearing the name was intentional, note that names cannot be cleared — every role must have a unique non-null name
Example fix
// before
await fetch(`/api/v1/authz/roles/${id}`, {
method: 'PATCH',
body: JSON.stringify({ name: null, description: 'updated' }),
});
// after
await fetch(`/api/v1/authz/roles/${id}`, {
method: 'PATCH',
body: JSON.stringify({ description: 'updated' }), // name key omitted
}); Defensive patterns
Strategy: validation
Validate before calling
function buildRolePatch(payload) {
const body = {};
if (payload.description !== undefined) body.description = payload.description;
if (payload.name !== undefined) {
if (payload.name === null) throw new Error('name cannot be null — omit the field instead');
body.name = payload.name;
}
return body;
} Type guard
const isValidRoleNamePatch = (name: unknown): name is string => name === undefined || (typeof name === 'string' && name.length > 0);
Prevention
- Serialize PATCH bodies with unset-field omission (exclude_unset semantics), never null-filling
- Treat name as an immutable-ish field: only include it when the user actually typed a new one
When it happens
Trigger: PATCH /authz/roles/{id} with body {"name": null}; a client that serializes a full RoleUpdate model with unset optional fields as explicit nulls instead of omitting them.
Common situations: Frontend forms that build a PATCH payload from a state object where the name field was cleared; JSON serializers configured with exclude_none=false; auto-generated OpenAPI clients that always include every field.
Related errors
- permissions cannot be null; pass an empty list to clear
- Unknown permission_level {payload.permission_level!r}
- parent_role_id does not reference an existing role
- A role cannot be its own parent
- Name conflict — another role already uses this name
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/25af153f4a123c88.
Report an issue: GitHub.