{"record":{"id":"25af153f4a123c88","repo":"langflow-ai/langflow","slug":"name-cannot-be-null","errorCode":null,"errorMessage":"name cannot be null","messagePattern":"name cannot be null","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"src/backend/base/langflow/api/v1/authz_roles.py","lineNumber":212,"sourceCode":"                    detail=\"parent_role_id does not reference an existing role\",\n                )\n            if await _detect_parent_cycle(session, role_id=role.id, proposed_parent_id=payload.parent_role_id):\n                raise HTTPException(\n                    status_code=status.HTTP_400_BAD_REQUEST,\n                    detail=\"Setting this parent would create a role hierarchy cycle\",\n                )\n            role.parent_role_id = payload.parent_role_id\n\n    if \"description\" in fields_set:\n        # description is nullable on the DB side — None is a legitimate clear.\n        role.description = payload.description\n\n    if \"name\" in fields_set:\n        # name is NOT NULL + unique on the DB side; reject an explicit null at\n        # the boundary so the caller gets a clear 400 instead of an opaque\n        # IntegrityError that the catch block below mislabels as \"Name conflict\".\n        if payload.name is None:\n            raise HTTPException(\n                status_code=status.HTTP_400_BAD_REQUEST,\n                detail=\"name cannot be null\",\n            )\n        role.name = payload.name\n\n    if \"permissions\" in fields_set:\n        # permissions column is nullable=False (default_factory=list). An empty\n        # list is the natural \"clear\" — None would violate the constraint at\n        # commit, so reject it up front.\n        if payload.permissions is None:\n            raise HTTPException(\n                status_code=status.HTTP_400_BAD_REQUEST,\n                detail=\"permissions cannot be null; pass an empty list to clear\",\n            )\n        role.permissions = list(payload.permissions)\n\n    role.updated_at = datetime.now(timezone.utc)\n","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/authz_roles.py#L194-L230","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nawait fetch(`/api/v1/authz/roles/${id}`, {\n  method: 'PATCH',\n  body: JSON.stringify({ name: null, description: 'updated' }),\n});\n\n// after\nawait fetch(`/api/v1/authz/roles/${id}`, {\n  method: 'PATCH',\n  body: JSON.stringify({ description: 'updated' }), // name key omitted\n});","handlingStrategy":"validation","validationCode":"function buildRolePatch(payload) {\n  const body = {};\n  if (payload.description !== undefined) body.description = payload.description;\n  if (payload.name !== undefined) {\n    if (payload.name === null) throw new Error('name cannot be null — omit the field instead');\n    body.name = payload.name;\n  }\n  return body;\n}","typeGuard":"const isValidRoleNamePatch = (name: unknown): name is string =>\n  name === undefined || (typeof name === 'string' && name.length > 0);","tryCatchPattern":null,"preventionTips":["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"],"tags":["authz","api","roles","validation","patch"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}