Airflow DAG 中使用的连接未提供_decrypted_ 密码或额外的 - DAG 创作问题

Connection used in Airflow DAG is not providing _decrypted_ password or extra - DAG authoring issue

我正在扩展 Airflow:2.2.0 图像并尝试使用 DAG 中的连接通过自定义 Hook 发出 GET 请求。然而,无论我尝试什么,并遵循找到的任何建议,DAG 似乎都没有获得密码和额外字段的解密版本。

DAG 的输出正确显示了连接信息(按源代码在打印时指示的逻辑编辑),但尝试使用它或打印它不会解密密码。

I'm redacting all sensitive/personal info with [var_name] below

我尝试直接在 DAG 的 PythonOperator 中获取详细信息:

conn = BaseHook.get_connection(conn_id=[conn_id])
print(conn.password)
print(conn.extra)

并从导入的自定义挂钩中

# inside the PythonOperator
with JwtHook(conn_id=[conn_id]) as api:
    result = api.get_metadata()
    print(result)


# with JwtHook partially doing (again, redacted majority of code):
...
def get_conn(self):
    """
    Returns the connection used by the hook for querying data.
    Should in principle not be used directly.
    """

    # Return existing session if initiated
    if self._session is None:
        # Fetch config for the given connection (host, login, etc).
        config = self.get_connection(self._conn_id)
        print(config.extra)        
        print(config.extra_dejson)

        if not config.host or not self._extras.get("token_host"):
            raise ValueError(
                f"No (token)host specified in connection {self._conn_id}"
            )

        self._login = (config.login, config.password)
        print(self._login)

       ...

...

{base.py:79} INFO - Using connection to: id: [conn_id]. Host: [url], Port: None, Schema: None, Login: [username], Password: ***, extra: {'token_host': '***', 'user_id': ''}
{logging_mixin.py:109} INFO - {"token_host": "***","user_id": ""}
{logging_mixin.py:109} INFO - {'token_host': '***', 'user_id': ''}
{logging_mixin.py:109} INFO - ([username], '***')

我在耗尽互联网后尝试、遵循和实施的事情:

任何有助于对此进行排序的帮助都会很棒。我只是无法确定问题 - 并且可能我错误地使用了 Airflow。有趣的是,我没有收到任何错误(例如 here)。我想知道 DAG 执行者是否拥有与连接创建者相同的权利 - 但我无法 find/see 如何证实这种怀疑。

非常感谢任何帮助。感谢您提前阅读!

[编辑] 所以,我没有尝试从 CLI 运行 test 运行 DAG - 你知道什么 - 它有效!相反,我是从 UI 手动触发 DAG - 但因为我只有一个(管理员)用户 - 我不怀疑它不起作用。所以我很清楚这是某种创作问题。有人对如何正确设置有任何指示吗?谢谢!

这是意料之中的。日志中的 *** 只是一个标志,表明您的连接密码已被正确检索。 Airflow 支持自动屏蔽秘密——如果你不小心在日志中打印了这样的秘密,它将自动替换为“***”。您在日志中看到的事实意味着您已正确解密它。

https://airflow.apache.org/docs/apache-airflow/stable/security/secrets/mask-sensitive-values.html