<p dir="auto"><strong>Description</strong></p>
<p dir="auto">Hook for AWS SecretsManager</p>
<p dir="auto"><strong>Use case / motivation</strong></p>
<p dir="auto">Simplify interaction with AWS's SecretsManager service</p>
<h3 dir="auto">Apache Airflow version</h3>
<p dir="auto">2.2.3 (latest released)</p>
<h3 dir="auto">What happened</h3>
<p dir="auto">In case within the DAG definition we use both <code class="notranslate">params</code> and <code class="notranslate">on_success_callback</code> then after triggering the DAG from the UI (option "Trigger DAG") and the finish of the successful DAG run I got the <em>DAG Import Errors</em> error displayed in the UI.</p>
<p dir="auto">Issue is related with the <code class="notranslate">_serialize_params_dict</code> method of <code class="notranslate">BaseSerialization</code> class.<br>
Part of the error message:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="if f'{v.__module__}.{v.__class__.__name__}' == 'airflow.models.param.Param':
AttributeError: 'str' object has no attribute '__module__'"><pre class="notranslate"><code class="notranslate">if f'{v.__module__}.{v.__class__.__name__}' == 'airflow.models.param.Param':
AttributeError: 'str' object has no attribute '__module__'
</code></pre></div>
<p dir="auto">In consequence there is also no update in the <code class="notranslate">serialized_dag</code> table of backend db.</p>
<p dir="auto">Additionally:</p>
<ul dir="auto">
<li>using the script provided in this ticket <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1047636958" data-permission-text="Title is private" data-url="https://github.com/apache/airflow/issues/19471" data-hovercard-type="pull_request" data-hovercard-url="/apache/airflow/pull/19471/hovercard" href="https://github.com/apache/airflow/pull/19471">#19471</a> results in the successful serialization</li>
<li>making any change to the code results in the successful serialization</li>
</ul>
<p dir="auto">So error occurs only after the successful DAG run from UI (I did not check the output of the run from CLI or just scheduled run)</p>
<p dir="auto">In case we remove the <code class="notranslate">params</code> or <code class="notranslate">on_success_callback</code> attribute then there is no serialization error.</p>
<p dir="auto">To confirm this issue I set up completely new Airflow instance in separate virtualenv and still had the same issue.</p>
<h3 dir="auto">What you expected to happen</h3>
<p dir="auto">Successful serialization after the successful DAG run</p>
<h3 dir="auto">How to reproduce</h3>
<p dir="auto">To reproduce this error I prepared very simple DAG presented below.</p>
<p dir="auto">Additional information about the setup:</p>
<ul dir="auto">
<li>executor = LocalExecutor</li>
<li>sql_alchemy_conn = Postgres db</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from airflow import DAG
from airflow.utils import timezone
from airflow.operators.dummy import DummyOperator
from airflow.models.param import Param

def func_on_success(context):
    pass

with DAG(
    dag_id=&quot;test&quot;,
    start_date=timezone.datetime(2022, 1, 1),
    schedule_interval='@once',
    params={&quot;param_test&quot;: Param(&quot;param_value_test&quot;)},
    on_success_callback=func_on_success
) as dag:
    DummyOperator(task_id='task_1')"><pre class="notranslate"><code class="notranslate">from airflow import DAG
from airflow.utils import timezone
from airflow.operators.dummy import DummyOperator
from airflow.models.param import Param

def func_on_success(context):
    pass

with DAG(
    dag_id="test",
    start_date=timezone.datetime(2022, 1, 1),
    schedule_interval='@once',
    params={"param_test": Param("param_value_test")},
    on_success_callback=func_on_success
) as dag:
    DummyOperator(task_id='task_1')
</code></pre></div>
<p dir="auto">After successful execution of this DAG through "Trigger DAG" option in the UI the error should be displayed (of course after refresh of the webpage).</p>
<h3 dir="auto">Operating System</h3>
<p dir="auto">MacOS 12.1</p>
<h3 dir="auto">Versions of Apache Airflow Providers</h3>
<p dir="auto">n/a</p>
<h3 dir="auto">Deployment</h3>
<p dir="auto">Virtualenv installation</p>
<h3 dir="auto">Deployment details</h3>
<ul dir="auto">
<li>executor = LocalExecutor</li>
<li>sql_alchemy_conn = Postgres db</li>
</ul>
<h3 dir="auto">Anything else</h3>
<p dir="auto">There is one scenario in which there will be no error:</p>
<ul dir="auto">
<li>make some changes to the DAG code</li>
<li>in consequence DAG is serialized automatically</li>
<li>trigger DAG and finish it successfully within the <code class="notranslate">min_serialized_dag_update_interval</code> second</li>
</ul>
<p dir="auto">then there will be no error because serialization process will not start after the DAG run (at least this is my explanation).</p>
<h3 dir="auto">Are you willing to submit PR?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Yes I am willing to submit a PR!</li>
</ul>
<h3 dir="auto">Code of Conduct</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow this project's <a href="https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a></li>
</ul>