vincbeck commented on PR #41067:
URL: https://github.com/apache/airflow/pull/41067#issuecomment-2263582833

   I think there is another one, I am looking into it but you'll probably be 
faster than me. I think there is something off in `is_called_from_test_code`, 
some sessions are created in tests but `is_called_from_test_code` returns 
`False`. Example:
   
   ```
   ERROR 
tests/providers/amazon/aws/hooks/test_chime.py::TestChimeWebhookHook::test_build_chime_payload_message_length
 - RuntimeError: TracebackSessionForTests object was used but internal API is 
enabled. Only test code is allowed to use this object.
   Called from:
       /opt/airflow/airflow/utils/db.py: 132
        if not session.scalar(select(1).where(conn.__class__.conn_id == 
conn.conn_id)):
   
   You'll need to ensure you are making only RPC calls with this object. The 
stack list below will show where the TracebackSession object was called:
     File "/usr/local/bin/pytest", line 8, in <module>
       sys.exit(console_main())
     File "/opt/airflow/tests/providers/amazon/aws/hooks/test_chime.py", line 
46, in setup_method
       db.merge_conn(
     File "/opt/airflow/airflow/utils/session.py", line 97, in wrapper
       return func(*args, session=session, **kwargs)
     File "/opt/airflow/airflow/utils/db.py", line 132, in merge_conn
       if not session.scalar(select(1).where(conn.__class__.conn_id == 
conn.conn_id)):
   
   
   The stack list below will show where the TracebackSession object was created:
     File "/usr/local/bin/pytest", line 8, in <module>
       sys.exit(console_main())
     File "/opt/airflow/tests/providers/amazon/aws/hooks/test_chime.py", line 
46, in setup_method
       db.merge_conn(
     File "/opt/airflow/airflow/utils/session.py", line 96, in wrapper
       with create_session() as session:
     File "/usr/local/lib/python3.8/contextlib.py", line 113, in __enter__
       return next(self.gen)
   ```


-- 
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