{"record":{"id":"a3e4077105a1b171","repo":"langflow-ai/langflow","slug":"role-not-found","errorCode":null,"errorMessage":"Role not found","messagePattern":"Role not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"src/backend/base/langflow/api/v1/authz_roles.py","lineNumber":101,"sourceCode":"    stmt = select(AuthzRole)\n    if is_system is not None:\n        stmt = stmt.where(AuthzRole.is_system == is_system)\n    if name:\n        stmt = stmt.where(AuthzRole.name.ilike(f\"%{escape_like_pattern(name)}%\", escape=\"\\\\\"))\n    stmt = stmt.order_by(AuthzRole.name, AuthzRole.id).offset(offset).limit(limit)\n    rows = (await session.exec(stmt)).all()\n    return [RoleRead.model_validate(row) for row in rows]\n\n\n@router.get(\"/{role_id}\", response_model=RoleRead)\nasync def read_role(\n    role_id: UUID,\n    session: DbSession,\n    current_user: CurrentActiveUser,  # noqa: ARG001 — any authenticated user can read\n) -> RoleRead:\n    role = await session.get(AuthzRole, role_id)\n    if role is None:\n        raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=\"Role not found\")\n    return RoleRead.model_validate(role)\n\n\n@router.post(\"\", response_model=RoleRead, status_code=status.HTTP_201_CREATED)\n@router.post(\"/\", response_model=RoleRead, status_code=status.HTTP_201_CREATED)\nasync def create_role(\n    payload: RoleCreate,\n    current_user: CurrentActiveUser,\n    session: DbSession,\n) -> RoleRead:\n    \"\"\"Create a custom (non-system) role. Superuser-only.\"\"\"\n    _require_superuser(current_user)\n\n    if payload.parent_role_id is not None:\n        parent = await session.get(AuthzRole, payload.parent_role_id)\n        if parent is None:\n            raise HTTPException(\n                status_code=status.HTTP_400_BAD_REQUEST,","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/authz_roles.py#L83-L119","documentation":"Raised by GET /api/v1/authz/roles/{role_id} when the id does not match any AuthzRole row. Unlike the mutation routes this read is available to any authenticated user, and returns HTTP 404 'Role not found' with no body leak beyond the message.","triggerScenarios":"GET a role id that was deleted, a UUID typo, or an id from another environment/installation where the role table was seeded differently.","commonSituations":"Deep links to a role detail page that outlived the role, cached role ids in frontend state after an admin deletes roles, or cross-environment id copying.","solutions":["Handle 404 by redirecting to the roles list and clearing stale cached ids","Resolve roles by name via the list endpoint instead of persisting ids","Confirm the environment/DB the client targets"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const roles = await api.get('/api/v1/authz/roles');\nif (!roles.some(r => r.id === roleId)) throw new Error('role not found');","typeGuard":"const isUuid = (v: string): boolean =>\n  /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v);","tryCatchPattern":"catch (e) { if (e.status === 404) { clearCachedRole(roleId); navigate('/authz/roles'); } }","preventionTips":["Prefer name-based lookups over cached UUIDs","Handle 404 on role deep links by falling back to the list","Clear stale role ids from frontend state after deletions"],"tags":["authz","rbac","http-404","roles"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}