eladkal commented on issue #18010:
URL: https://github.com/apache/airflow/issues/18010#issuecomment-912808261
I was able to create both dag_id and task_id with non ascii char:
```
from airflow import DAG
from datetime import datetime
from airflow.operators.bash import BashOperator
default_args = {
'owner': 'airflow',
'start_date': datetime(2020, 3, 11),
}
with DAG(
dag_id='simple_non_ascii_ñ_ö',
default_args=default_args,
schedule_interval='8/15 * * * *',
) as dag:
BashOperator(
task_id='sleep_ñ_ö',
bash_command='sleep 5',
)
```

However I wasn't able to create with `♥O◘♦♥O◘♦`:

We use `validate_key`:
https://github.com/apache/airflow/blob/867e9305f08bf9580f25430d8b6e84071c59f9e6/airflow/utils/helpers.py#L45-L55
The regex is:
https://github.com/apache/airflow/blob/867e9305f08bf9580f25430d8b6e84071c59f9e6/airflow/utils/helpers.py#L37
validation is on both the `dag_id` and `task_id`:
https://github.com/apache/airflow/blob/867e9305f08bf9580f25430d8b6e84071c59f9e6/airflow/models/dag.py#L328
https://github.com/apache/airflow/blob/867e9305f08bf9580f25430d8b6e84071c59f9e6/airflow/models/baseoperator.py#L538
A possible fix is:
`KEY_REGEX = re.compile(r'^[\w.-]+$', re.ASCII)`
Some examples:
```
import re
KEY_REGEX = re.compile(r'^[\w.-]+$')
KEY_REGEX_NEW = re.compile(r'^[\w.-]+$', re.ASCII)
strings = ["ascii_a_b", "ascii_ñ_ö", "♥O◘♦♥O◘♦"]
for string in strings:
print(f"\nresult for {string}:")
print(KEY_REGEX.match(string))
print(KEY_REGEX_NEW.match(string))
```
gives:
```
result for ascii_a_b:
<_sre.SRE_Match object; span=(0, 9), match='ascii_a_b'>
<_sre.SRE_Match object; span=(0, 9), match='ascii_a_b'>
result for ascii_ñ_ö:
<_sre.SRE_Match object; span=(0, 9), match='ascii_ñ_ö'>
None
result for ♥O◘♦♥O◘♦:
None
None
```
adding `re.ASCII` will show broken dag as expected:

@potiuk WDYT?
--
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]