Skip to content

DAG code syntax highlighting is incorrect with f-strings #67986

Description

@zhaorui2022

Under which category would you file this issue?

Airflow Core

Apache Airflow version

3.2.2

What happened and how to reproduce it?

When using operators with f-strings, the code syntax highlighting is incorrect.

An example to reproduce the issue

    table_name = "example_catalog.example_schema.example_table"

    validate_data = DatabricksSqlOperator(
        task_id="validate_data",
        sql=f"""
        SELECT CASE WHEN COUNT(*) = 0 THEN 1 ELSE 0 END
        FROM {table_name}
        WHERE ds = '{{{{ ds }}}}'
        """,
        databricks_conn_id="databricks_default",
    )

This is rendered like this

Image

What you think should happen instead?

FROM {table_name}
WHERE ds = '{{{{ ds }}}}'

should be red
and

,
databricks_conn_id="databricks_default",

should be black

Operating System

Debian GNU/Linux 12 (bookworm)

Deployment

None

Apache Airflow Provider(s)

No response

Versions of Apache Airflow Providers

No response

Official Helm Chart version

Not Applicable

Kubernetes Version

No response

Helm Chart configuration

No response

Docker Image customizations

Used the official docker image for 3.2.2

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

    area:UIRelated to UI/UX. For Frontend Developers.kind:bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yet

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions