yjwong opened a new issue #13985:
URL: https://github.com/apache/airflow/issues/13985


   **Apache Airflow version**: 2.0.0 with the following patch: 
https://github.com/apache/airflow/pull/13640
   
   
   **Kubernetes version (if you are using kubernetes)** (use `kubectl 
version`): N/A
   
   **Environment**:
   
   - **Cloud provider or hardware configuration**: AMD Ryzen 3900X (12C/24T), 
64GB RAM
   - **OS** (e.g. from /etc/os-release): Ubuntu 20.04.1 LTS
   - **Kernel** (e.g. `uname -a`): 5.9.8-050908-generic
   - **Install tools**: N/A
   - **Others**: N/A
   
   **What happened**:
   
   If there are custom hooks that implement the `get_connection_form_widgets` 
method that return fields using the `InputRequired` validator, saving breaks 
for all types of connections on the "Edit Connections" page.
   
   In Chrome, the following message is logged to the browser console:
   
   ```
   An invalid form control with name='extra__hook_name__field_name' is not 
focusable.
   ```
   
   This happens because the field is marked as `<input required>` but is hidden 
using CSS when the connection type exposed by the custom hook is not selected.
   
   **What you expected to happen**:
   
   Should be able to save other types of connections.
   
   **How to reproduce it**:
   
   Create a provider, and add a hook with something like:
   
   ```python
       @staticmethod
       def get_connection_form_widgets() -> Dict[str, Any]:
           """Returns connection widgets to add to connection form."""
           return {
               'extra__my_hook__client_id': StringField(
                   lazy_gettext('OAuth2 Client ID'),
                   widget=BS3TextFieldWidget(),
                   validators=[wtforms.validators.InputRequired()],
               ),
           }
   ```
   
   Go to the Airflow Web UI, click the "Add" button in the connection list 
page, then choose a connection type that's not the type exposed by the custom 
hook. Fill in details and click "Save".
   
   **Anything else we need to know**: N/A
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to