code: def sanitize_conn_id(
      conn_id: str | None, max_length=CONN_ID_MAX_LEN
  ) -> str | None:
      r"""Sanitizes the connection id and allows only specific characters to be within.
  
      Namely, it allows alphanumeric characters plus the symbols #,!,-,_,.,:,\,/ and () from 1 and up to
      250 consecutive matches. If desired, the max length can be adjusted by setting `max_length`.
  
      You can try to play with the regex here: https://regex101.com/r/69033B/1
  
      The character selection is such that it prevents the injection of javascript or
      executable bits to avoid any awkward behaviour in the front-end.
  
      :param conn_id: The connection id to sanitize.
      :param max_length: The max length of the connection ID, by default it is 250.
      :return: the sanitized string, `None` otherwise.
      """
      # check if `conn_id` or our match group is `None` and the `conn_id` is within the specified length.
      if (
          not isinstance(conn_id, str) or len(conn_id) > max_length
      ) or (res := re2.match(RE_SANITIZE_CONN_ID, conn_id)) is None:
          return None
  
      # if we reach here, then we matched something, return the first match
      return res.group(0)
  
imports: from __future__ import annotations
  import json
  import logging
  import warnings
  from json import JSONDecodeError
  from typing import Any
  from urllib.parse import parse_qsl, quote, unquote, urlencode, urlsplit
  import re2
  from sqlalchemy import Boolean, Column, Integer, String, Text
  from sqlalchemy.orm import declared_attr, reconstructor, synonym
  from airflow.configuration import ensure_secrets_loaded
  from airflow.exceptions import AirflowException, AirflowNotFoundException, RemovedInAirflow3Warning
  from airflow.models.base import ID_LEN, Base
  from airflow.models.crypto import get_fernet
  from airflow.secrets.cache import SecretCache
  from airflow.utils.helpers import prune_dict
  from airflow.utils.log.logging_mixin import LoggingMixin
  from airflow.utils.log.secrets_masker import mask_secret
  from airflow.utils.module_loading import import_string
label_desc: Use image node_id 2 for calling a global function with example usage: sanitize_conn_id(conn_id, max_length) and returns: res, None