Skip to content

structlog.dev.Styles can not be imported in newest structlog #57419

@dada-engineer

Description

@dada-engineer

Apache Airflow version

3.1.1

If "Other Airflow 2/3 version" selected, which one?

No response

What happened?

structlog released a new version yesterday and since then configure_logging fails with

Traceback (most recent call last):
  File "/home/airflow/.local/bin/airflow", line 3, in <module>
    from airflow.__main__ import main
  File "/home/airflow/.local/lib/python3.12/site-packages/airflow/__init__.py", line 79, in <module>
    settings.initialize()
  File "/home/airflow/.local/lib/python3.12/site-packages/airflow/settings.py", line 698, in initialize
    LOGGING_CLASS_PATH = configure_logging()
                         ^^^^^^^^^^^^^^^^^^^
  File "/home/airflow/.local/lib/python3.12/site-packages/airflow/logging_config.py", line 88, in configure_logging
    from airflow._shared.logging import configure_logging, init_log_folder, translate_config_values
  File "/home/airflow/.local/lib/python3.12/site-packages/airflow/_shared/logging/__init__.py", line 27, in <module>
    from .structlog import configure_logging, init_log_file, init_log_folder
  File "/home/airflow/.local/lib/python3.12/site-packages/airflow/_shared/logging/structlog.py", line 38, in <module>
    from .percent_formatter import PercentFormatRender
  File "/home/airflow/.local/lib/python3.12/site-packages/airflow/_shared/logging/percent_formatter.py", line 29, in <module>
    from structlog.dev import ConsoleRenderer, Styles
ImportError: cannot import name 'Styles' from 'structlog.dev' (/home/airflow/.local/lib/python3.12/site-packages/structlog/dev.py)

Workaround for us for now is to pin structlog to version < 25.5.0

What you think should happen instead?

Styles should be imported from the correct module

How to reproduce

run airflow db check for example.

Operating System

debian (official airflow 3.1.1-slim-python3.12 docker image)

Versions of Apache Airflow Providers

No response

Deployment

Official Apache Airflow Helm Chart

Deployment details

We do build a docker container with dags and custom requirements. It is based on the official 3.1.1-slim-python3.12 chart

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions