darkag opened a new issue, #64835:
URL: https://github.com/apache/airflow/issues/64835

   ### Under which category would you file this issue?
   
   Airflow Core
   
   ### Apache Airflow version
   
   2.10.5
   
   ### What happened and how to reproduce it?
   
   In airflow 2.10+, defining custom validation for connection form doesn't 
work correctly. Validation is called but error message is maked by the overall 
warning message "Warning: Fields that are currently populated..."
   
   as a example : 
   ```python
       @classmethod
       def get_connection_form_widgets(cls) -> dict[str, Any]:
           """Return connection widgets to add to connection form."""
           from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
           from flask_babel import lazy_gettext
           from flask import flash
           from wtforms.validators import Optional, ValidationError
   
           def validate_cms_authentication(form, field):
               valid = {"secEnterprise", "secLDAP", "secWinAD", "secSAPR3"}
               if field.data and field.data not in valid:
                   flash("valeur non valide", "error")
                   raise ValidationError(
                       "Valeur invalide. Choisir parmi : secEnterprise, 
secLDAP, secWinAD, secSAPR3"
                   )
           from wtforms import StringField
   
           return {
               "cms_system": StringField(
                   lazy_gettext("Système"), widget=BS3TextFieldWidget()
               ),
               "cms_authentication": StringField(
                   lazy_gettext("Authentification"),
                   description="Méthode d'authentication (secEnterprise, 
secLDAP, secWinAD, secSAPR3)",
                   widget=BS3TextFieldWidget(),
                   default="secEnterprise",
                   validators=[Optional(), validate_cms_authentication],
               ),
           }
   ```
   
   <img width="1804" height="123" alt="Image" 
src="https://github.com/user-attachments/assets/c50af8e3-1f0c-438a-a3cf-5cb9111a848a";
 />
   
   Seems that the selector of displayAlert in 
https://github.com/apache/airflow/blob/v2-11-stable/airflow/www/static/js/connection_form.js
 is too large and include others error message
   
   ```javascript
     /**
      * Displays the Flask style alert on UI via JS
      *
      * @param {string} status - Status can be either success, error, or warning
      * @param {string} message - The text message to show in alert box
      */
     function displayAlert(status, message) {
       const alertClass = `alert-${status}`;
       let alertBox = $(".container .row .alert");
       if (alertBox.length) {
         alertBox.removeClass("alert-success").removeClass("alert-error");
         alertBox.addClass(alertClass);
         alertBox.text(message);
         alertBox.show();
       } else {
         alertBox = $(
           `<div class="alert ${alertClass}">\n` +
             `<button type="button" class="close" 
data-dismiss="alert">×</button>\n${message}</div>`,
         );
   
         $(".container .row").prepend(alertBox).show();
       }
     }
   
     displayAlert(
       "warning",
       "Warning: Fields that are currently populated can be modified but cannot 
be deleted. To delete data from a field, delete the Connection object and 
create a new one.",
     );
   ```
   
   
   
   ### What you think should happen instead?
   
   Validation error messages should be displayed
   
   ### Operating System
   
   _No response_
   
   ### Deployment
   
   None
   
   ### Apache Airflow Provider(s)
   
   _No response_
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   _No response_
   
   ### Helm Chart configuration
   
   _No response_
   
   ### Docker Image customizations
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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

To unsubscribe, e-mail: [email protected]

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

Reply via email to