You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Kim-frau (via GitHub)" <gi...@apache.org> on 2024/06/14 15:34:53 UTC

[I] Alerting and reports does not take EMAIL RECIPIENTS* [superset]

Kim-frau opened a new issue, #29256:
URL: https://github.com/apache/superset/issues/29256

   ### Bug description
   
   Unable to save an alert since notification method is allways in red
   
   ### How to reproduce the bug
   
   Try to create an alert or a report and follow the steps, unable to save it. 
   Also, unable to modify the email recipients of old alerts coming from the 3.1.2 version of superset
   
   ### Screenshots/recordings
   
   
   ![Capture d’écran 2024-06-14 173314](https://github.com/apache/superset/assets/77016083/237af436-b5ad-453d-a680-e259ff96efb7)
   
   
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.9
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [ ] I have searched Superset docs and Slack and didn't find a solution to my problem.
   - [ ] I have searched the GitHub issue tracker and didn't find a similar bug report.
   - [ ] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.


-- 
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: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Alerting and reports does not take EMAIL RECIPIENTS* [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #29256:
URL: https://github.com/apache/superset/issues/29256#issuecomment-2168301188

   <!-- Answer -->
   The issues you are experiencing with saving an alert in Superset and modifying the email recipients of old alerts are likely due to the validation and state management logic in the `AlertReportModal` component.
   
   1. **Notification Method Highlighted in Red:**
      The notification method is highlighted in red because the validation logic checks if all required fields are complete before enabling the save button. Specifically, the `validateNotificationSection` function checks if the notification settings have the required information, including the recipients. If the recipients are not provided, it marks the section as having errors, which results in the notification method being highlighted in red.
   
      ```tsx
      const validateNotificationSection = () => {
        const hasErrors = !checkNotificationSettings();
        const errors = hasErrors ? [TRANSLATIONS.RECIPIENTS_ERROR_TEXT] : [];
   
        if (emailError) {
          errors.push(TRANSLATIONS.EMAIL_SUBJECT_ERROR_TEXT);
        }
   
        updateValidationStatus(Sections.Notification, errors);
      };
   
      const checkNotificationSettings = () => {
        if (!notificationSettings.length) {
          return false;
        }
   
        let hasInfo = false;
   
        notificationSettings.forEach(setting => {
          if (!!setting.method && setting.recipients?.length) {
            hasInfo = true;
          }
        });
   
        return hasInfo;
      };
      ```
   
   2. **Unable to Modify Email Recipients of Old Alerts:**
      The inability to modify email recipients of old alerts created in version 3.1.2 could be due to the way the notification settings are initialized and managed. When an alert is fetched, the notification settings are populated based on the recipients from the resource. If the recipients are not correctly parsed or if the allowed notification methods do not match the existing methods, it could prevent modifications.
   
      ```tsx
      useEffect(() => {
        if (resource) {
          // Add notification settings
          const settings = (resource.recipients || []).map(setting => {
            const config =
              typeof setting.recipient_config_json === 'string'
                ? JSON.parse(setting.recipient_config_json)
                : {};
            return {
              method: setting.type,
              // @ts-ignore: Type not assignable
              recipients: config.target || setting.recipient_config_json,
              options: allowedNotificationMethods,
            };
          });
   
          setNotificationSettings(settings);
          setNotificationAddState(
            settings.length === allowedNotificationMethods.length
              ? 'hidden'
              : 'active',
          );
        }
      }, [resource]);
      ```
   
      Ensure that the `allowedNotificationMethods` includes the methods used in old alerts and that the recipients are correctly parsed and assigned.
   
   Additionally, the `NotificationMethod` component handles the rendering and validation of the notification method and recipients. If the recipients are not correctly set or if there are validation errors, the component will highlight the input fields in red.
   
   ```tsx
   const onRecipientsChange = (
     event: React.ChangeEvent<HTMLTextAreaElement>,
   ) => {
     const { target } = event;
   
     setRecipientValue(target.value);
   
     if (onUpdate) {
       const updatedSetting = {
         ...setting,
         recipients: target.value,
       };
   
       onUpdate(index, updatedSetting);
     }
   };
   ```
   
   To resolve these issues, you need to ensure that all required fields, including the notification method and recipients, are correctly filled out and validated. Additionally, verify that the initialization logic for old alerts correctly parses and assigns the recipients and notification methods <sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/src/features/alerts/AlertReportModal.tsx)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset-frontend/src/features/alerts/components/NotificationMethod.tsx)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] 4.0.1: Alerting and reports does not take EMAIL RECIPIENTS* [superset]

Posted by "Kim-frau (via GitHub)" <gi...@apache.org>.
Kim-frau commented on issue #29256:
URL: https://github.com/apache/superset/issues/29256#issuecomment-2172470726

   Great, thanks


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] 4.0.1: Alerting and reports does not take EMAIL RECIPIENTS* [superset]

Posted by "Kim-frau (via GitHub)" <gi...@apache.org>.
Kim-frau closed issue #29256: 4.0.1: Alerting and reports does not take EMAIL RECIPIENTS*
URL: https://github.com/apache/superset/issues/29256


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] 4.0.1: Alerting and reports does not take EMAIL RECIPIENTS* [superset]

Posted by "Kim-frau (via GitHub)" <gi...@apache.org>.
Kim-frau commented on issue #29256:
URL: https://github.com/apache/superset/issues/29256#issuecomment-2172471512

   Allready taken care in https://github.com/apache/superset/pull/28409 


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] 4.0.1: Alerting and reports does not take EMAIL RECIPIENTS* [superset]

Posted by "akiellor (via GitHub)" <gi...@apache.org>.
akiellor commented on issue #29256:
URL: https://github.com/apache/superset/issues/29256#issuecomment-2172025820

   It looks like this has been resolved in [this](https://github.com/apache/superset/pull/28409) Pull Request. But has not yet been released.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org