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

change IntegrationsConnectionStatus provider field to string #406

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

refaelm92
Copy link
Contributor

@refaelm92 refaelm92 commented Dec 3, 2024

PR Type

enhancement


Description

  • Changed the type of the Provider field in the IntegrationsConnectionStatus struct from ChannelProvider to string.
  • This change likely simplifies the handling of provider information by using a basic data type.

Changes walkthrough 📝

Relevant files
Enhancement
collaborationconfig.go
Modify `Provider` field type to string in struct                 

notifications/collaborationconfig.go

  • Changed the Provider field type from ChannelProvider to string in
    IntegrationsConnectionStatus.
  • +1/-1     

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

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

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

    Type Validation
    Changing from ChannelProvider enum to string removes type safety. Need to verify that all code using this field properly validates the provider string values.

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Implement string validation to maintain type safety when converting from an enum to a string field

    Consider validating the string value of Provider to ensure it matches expected
    provider types, since changing from ChannelProvider enum to string removes type
    safety.

    notifications/collaborationconfig.go [90-93]

     type IntegrationsConnectionStatus struct {
    -    Provider string                      `json:"provider"`
    +    Provider ProviderType                `json:"provider"`
         Status   IntegrationConnectionStatus `json:"status"`
     }
     
    +type ProviderType string
    +
    +func (p ProviderType) Validate() error {
    +    validTypes := []ProviderType{"slack", "teams", "email"} // add your valid types
    +    for _, t := range validTypes {
    +        if p == t {
    +            return nil
    +        }
    +    }
    +    return fmt.Errorf("invalid provider type: %s", p)
    +}
    +
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: The suggestion addresses a significant potential issue where changing from a strongly-typed enum (ChannelProvider) to a string removes type safety, which could lead to runtime errors. The proposed solution of adding validation maintains data integrity while providing clear error messaging.

    8

    💡 Need additional feedback ? start a PR chat

    @refaelm92 refaelm92 merged commit 84c6622 into main Dec 3, 2024
    3 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants