Jeoffreybauvin opened a new issue, #63336:
URL: https://github.com/apache/airflow/issues/63336

   ### Apache Airflow version
   
   3.1.7
   
   ### If "Other Airflow 3 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   When trying to delete a role with endpoint /auth/fab/v1/roles/TestRole, the 
"TestRole" is not delete : 
   
   ```
   curl -X DELETE -k -H 'Content-Type: application/json' -H 'Authorization: 
Bearer ...' https://airflow/auth/fab/v1/roles/TestRole                          
                                                                                
          
   Internal Server Error
   ```
   
   ```
   INFO:     172.27.2.1:53960 - "DELETE /auth/fab/v1/roles/TestRole HTTP/1.1" 
500 Internal Server Error
   ERROR:    Exception in ASGI application
   Traceback (most recent call last):
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/coercions.py",
 line 804, in _literal_coercion
       return expr._bind_param(operator, element, type_=bindparam_type)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/elements.py", 
line 4669, in _bind_param
       return BindParameter(
              ^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/elements.py", 
line 2055, in __init__
       self.type = _compared_to_type.coerce_compared_value(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/type_api.py", 
line 1065, in coerce_compared_value
       _coerced_type = _resolve_value_to_type(value)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/sqltypes.py", 
line 3911, in _resolve_value_to_type
       raise exc.ArgumentError(
   sqlalchemy.exc.ArgumentError: Object TestRole is not legal as a SQL literal 
value
   
   The above exception was the direct cause of the following exception:
   Traceback (most recent call last):
     File 
"/home/airflow/.local/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py",
 line 416, in run_asgi
       result = await app(  # type: ignore[func-returns-value]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/fastapi/applications.py", 
line 1082, in __call__
       await super().__call__(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/applications.py", 
line 113, in __call__
       await self.middleware_stack(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/errors.py",
 line 186, in __call__
       raise exc
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/errors.py",
 line 164, in __call__
       await self.app(scope, receive, _send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/gzip.py",
 line 29, in __call__
       await responder(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/gzip.py",
 line 46, in __call__
       await self.app(scope, receive, self.send_with_compression)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/cors.py",
 line 85, in __call__
       await self.app(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/base.py",
 line 189, in __call__
       raise app_exc
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/base.py",
 line 144, in coro
       await self.app(scope, receive_or_disconnect, send_no_error)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/exceptions.py",
 line 63, in __call__
       await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py",
 line 53, in wrapped_app
       raise exc
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py",
 line 42, in wrapped_app
       await app(scope, receive, sender)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 
716, in __call__
       await self.middleware_stack(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 
736, in app
       await route.handle(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 
462, in handle
       await self.app(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/fastapi/applications.py", 
line 1082, in __call__
       await super().__call__(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/applications.py", 
line 113, in __call__
       await self.middleware_stack(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/errors.py",
 line 186, in __call__
       raise exc
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/errors.py",
 line 164, in __call__
       await self.app(scope, receive, _send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/exceptions.py",
 line 63, in __call__
       await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py",
 line 53, in wrapped_app
       raise exc
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py",
 line 42, in wrapped_app
       await app(scope, receive, sender)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 
716, in __call__
       await self.middleware_stack(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 
736, in app
       await route.handle(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 
290, in handle
       await self.app(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 
78, in app
       await wrap_app_handling_exceptions(app, request)(scope, receive, send)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py",
 line 53, in wrapped_app
       raise exc
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py",
 line 42, in wrapped_app
       await app(scope, receive, sender)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 
75, in app
       response = await f(request)
                  ^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/fastapi/routing.py", line 
308, in app
       raw_response = await run_endpoint_function(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/fastapi/routing.py", line 
221, in run_endpoint_function
       return await run_in_threadpool(dependant.call, **values)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/starlette/concurrency.py", 
line 38, in run_in_threadpool
       return await anyio.to_thread.run_sync(func)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/anyio/to_thread.py", line 
63, in run_sync
       return await get_async_backend().run_sync_in_worker_thread(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py",
 line 2502, in run_sync_in_worker_thread
       return await future
              ^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py",
 line 986, in run
       result = context.run(func, *args)
                ^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/fab/auth_manager/api_fastapi/routes/roles.py",
 line 102, in delete_role
       return FABAuthManagerRoles.delete_role(name=name)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/fab/auth_manager/api_fastapi/services/roles.py",
 line 110, in delete_role
       security_manager.delete_role(existing)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/fab/auth_manager/security_manager/override.py",
 line 1324, in delete_role
       role = self.session.scalars(select(Role).where(Role.name == 
role_name)).first()
                                                      ^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/operators.py",
 line 584, in __eq__
       return self.operate(eq, other)
              ^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py",
 line 453, in operate
       return op(self.comparator, *other, **kwargs)  # type: 
ignore[no-any-return]  # noqa: E501
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/operators.py",
 line 584, in __eq__
       return self.operate(eq, other)
              ^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/properties.py",
 line 479, in operate
       return op(self.__clause_element__(), *other, **kwargs)  # type: 
ignore[no-any-return]  # noqa: E501
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/annotation.py",
 line 371, in __eq__
       return self.__element.__class__.__eq__(self, other)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/operators.py",
 line 584, in __eq__
       return self.operate(eq, other)
              ^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/elements.py", 
line 1535, in operate
       return op(self.comparator, *other, **kwargs)  # type: 
ignore[no-any-return]  # noqa: E501
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/operators.py",
 line 584, in __eq__
       return self.operate(eq, other)
              ^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/type_api.py", 
line 210, in operate
       return op_fn(self.expr, op, *other, **addtl_kw)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/default_comparator.py",
 line 120, in _boolean_compare
       obj = coercions.expect(
             ^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/coercions.py",
 line 396, in expect
       resolved = impl._literal_coercion(
                  ^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/coercions.py",
 line 806, in _literal_coercion
       self._raise_for_expected(element, err=err)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/coercions.py",
 line 785, in _raise_for_expected
       return super()._raise_for_expected(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/coercions.py",
 line 519, in _raise_for_expected
       raise exc.ArgumentError(msg, code=code) from err
   sqlalchemy.exc.ArgumentError: SQL expression element or literal value 
expected, got TestRole.
   ```
   
   The role deletion is working with the UI.
   
   ### What you think should happen instead?
   
   The role should be deleted.
   
   ### How to reproduce
   
   Just create a role with and try to delete it with 
/auth/fab/v1/roles/TestRole.
   
   
   
   ### Operating System
   
   Docker on Ubuntu 24.04
   
   ### Versions of Apache Airflow Providers
   
   ```
   airflow@4652d74a3fe8:/opt/airflow$ pip freeze | grep providers
   apache-airflow-providers-amazon==9.21.0
   apache-airflow-providers-celery==3.15.2
   apache-airflow-providers-cncf-kubernetes==10.12.3
   apache-airflow-providers-common-compat==1.13.0
   apache-airflow-providers-common-io==1.7.1
   apache-airflow-providers-common-messaging==2.0.2
   apache-airflow-providers-common-sql==1.30.4
   apache-airflow-providers-docker==4.5.2
   apache-airflow-providers-elasticsearch==6.4.4
   apache-airflow-providers-fab==3.2.0
   apache-airflow-providers-ftp==3.14.1
   apache-airflow-providers-git==0.2.2
   apache-airflow-providers-google==19.5.0
   apache-airflow-providers-grpc==3.9.2
   apache-airflow-providers-hashicorp==4.4.3
   apache-airflow-providers-http==5.6.4
   apache-airflow-providers-microsoft-azure==12.10.3
   apache-airflow-providers-mysql==6.4.2
   apache-airflow-providers-odbc==4.11.1
   apache-airflow-providers-openlineage==2.10.1
   apache-airflow-providers-postgres==6.5.3
   apache-airflow-providers-redis==4.4.2
   apache-airflow-providers-sendgrid==4.2.1
   apache-airflow-providers-sftp==5.7.0
   apache-airflow-providers-slack==9.6.2
   apache-airflow-providers-smtp==2.4.2
   apache-airflow-providers-snowflake==6.9.0
   apache-airflow-providers-ssh==4.3.1
   apache-airflow-providers-standard==1.11.0
   
   ```
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to