Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLA-2094] Fixes email validation on linux #56

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

leonardocustodio
Copy link
Contributor

@leonardocustodio leonardocustodio commented Jan 20, 2025

PR Type

Bug fix


Description

  • Updated email validation logic in start.sh.

  • Replaced regex validation with a case pattern check.

  • Improved user feedback for invalid email input.


Changes walkthrough 📝

Relevant files
Bug fix
start.sh
Refactor email validation logic in `start.sh`                       

start.sh

  • Replaced regex-based email validation with a case pattern check.
  • Enhanced user feedback for invalid email inputs.
  • Simplified validation logic for better maintainability.
  • +7/-4     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Signed-off-by: Leonardo Custodio <leonardo@enjin.io>
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Validation Logic Change

    The email validation logic has been replaced with a case pattern check. Ensure that the new pattern *@?*.?* is robust enough to handle common email formats and edge cases.

    case $NOTIFICATION_EMAIL in
        *@?*.?*) ;;  # Valid pattern
        *)
            echo "The email address you provided is not valid. Please try again."
            read_email
            ;;
    esac

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add termination condition to recursion

    Ensure the read_email function handles invalid email inputs robustly by adding a
    termination condition to prevent infinite recursion in case the user repeatedly
    provides invalid email addresses.

    start.sh [58-64]

     case $NOTIFICATION_EMAIL in
         *@?*.?*) ;;  # Valid pattern
         *)
             echo "The email address you provided is not valid. Please try again."
    +        if [ "$RETRY_COUNT" -ge 3 ]; then
    +            echo "Too many invalid attempts. Exiting."
    +            return
    +        fi
    +        RETRY_COUNT=$((RETRY_COUNT + 1))
             read_email
             ;;
     esac
    Suggestion importance[1-10]: 9

    Why: The suggestion addresses a critical issue of potential infinite recursion in the read_email function by introducing a termination condition after a certain number of invalid attempts. This improves the robustness and reliability of the script, preventing it from getting stuck in an endless loop due to user error. The implementation is accurate and directly relevant to the PR changes.

    9

    @leonardocustodio leonardocustodio self-assigned this Jan 20, 2025
    @leonardocustodio leonardocustodio changed the title Update start.sh Fixes email validation on linux Jan 20, 2025
    @leonardocustodio leonardocustodio changed the title Fixes email validation on linux [PLA-2094] Fixes email validation on linux Jan 20, 2025
    @leonardocustodio leonardocustodio merged commit c90646e into master Jan 20, 2025
    1 check passed
    @leonardocustodio leonardocustodio deleted the bugfix/PLA-2094/telemetry branch January 20, 2025 15:28
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Development

    Successfully merging this pull request may close these issues.

    3 participants