<h3 dir="auto">What happened</h3>
<p dir="auto">When entering a conn_id in the Connections section, there is currently no form validation in place. This allows users to input a conn_id with a space at the end for example, which results in errors when running tasks. The error message displayed states that the connection doesn't exist, which can be misleading and time-consuming to debug.</p>
<h3 dir="auto">What you think should happen instead</h3>
<p dir="auto">Form validation should be added to the Connections section to prevent conn_id inputs with trailing spaces from being saved and instead save the conn_id without the trailing spaces.</p>
<h3 dir="auto">How to reproduce</h3>
<ul dir="auto">
<li>Go to the Connections section of the application.</li>
<li>Enter a conn_id with a space at the end.</li>
<li>Save the form or attempt to run a task with the conn_id.</li>
</ul>
<h3 dir="auto">Operating System</h3>
<p dir="auto">Linux - Ubuntu 20.04</p>
<h3 dir="auto">Versions of Apache Airflow Providers</h3>
<p dir="auto">2.5.1</p>
<h3 dir="auto">Deployment</h3>
<p dir="auto">Docker-Compose</p>
<h3 dir="auto">Deployment details</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Anything else</h3>
<p dir="auto"><em>No response</em></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" checked=""> 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>
<h3 dir="auto">Description</h3>
<p dir="auto">I bumped into a bug where a connection id was suffixed with a whitespace e.g. "myconn ". When referencing the connection id "myconn" (without whitespace), you get a connection not found error.</p>
<p dir="auto">To avoid such human errors, I suggest restricting the characters allowed for connection ids.</p>
<p dir="auto">Some suggestions:</p>
<ul dir="auto">
<li>There's an <code class="notranslate">airflow.utils.helpers.validate_key</code> function for validating the DAG id. Probably a good idea to reuse this.</li>
<li>I believe variable ids are also not validated, would be good to check those too.</li>
</ul>
<h3 dir="auto">Use case/motivation</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Related issues</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Are you willing to submit a PR?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> 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>