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

[Core] Validate feature flag for get config in new integrations #1419

Merged
merged 1 commit into from
Feb 23, 2025

Conversation

erikzaadi
Copy link
Member

@erikzaadi erikzaadi commented Feb 23, 2025

User description

Description

Ensure that the provisioning feature flag is verified when polling integations

Type of change

Please leave one option from the following and delete the rest:

  • Bug fix (non-breaking change which fixes an issue)

PR Type

Bug fix


Description

  • Validate the feature flag USE_PROVISIONED_DEFAULTS during integration polling.

  • Ensure proper feature flag verification for provisioning logic.

  • Refactor conditional logic for better readability and maintainability.


Changes walkthrough 📝

Relevant files
Bug fix
integrations.py
Add feature flag validation in integration logic                 

port_ocean/clients/port/mixins/integrations.py

  • Added ORG_USE_PROVISIONED_DEFAULTS_FEATURE_FLAG constant for feature
    flag validation.
  • Updated get_current_integration method to include feature flag
    verification.
  • Refactored conditional logic for checking provisioning enablement.
  • +13/-7   

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @erikzaadi erikzaadi requested a review from a team as a code owner February 23, 2025 10:43
    Copy link
    Contributor

    Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

    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

    Error Handling

    The feature flag check could fail silently if the get_organization_feature_flags() call fails. Consider adding explicit error handling.

        ORG_USE_PROVISIONED_DEFAULTS_FEATURE_FLAG
        in (await self.client.get_organization_feature_flags())
    )

    Copy link
    Contributor

    qodo-merge-pro bot commented Feb 23, 2025

    Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Add error handling for API call

    Add error handling for the feature flags API call to prevent potential runtime
    errors if the request fails.

    port_ocean/clients/port/mixins/integrations.py [89-90]

    -ORG_USE_PROVISIONED_DEFAULTS_FEATURE_FLAG
    -in (await self.client.get_organization_feature_flags())
    +try:
    +    org_feature_flags = await self.client.get_organization_feature_flags()
    +    ORG_USE_PROVISIONED_DEFAULTS_FEATURE_FLAG in org_feature_flags
    +except Exception as e:
    +    logger.error(f"Failed to fetch organization feature flags: {e}")
    +    return False
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    __

    Why: Adding error handling for the feature flags API call is crucial to prevent potential runtime crashes and ensure graceful degradation of functionality when the API request fails.

    Medium
    Validate feature flags response type

    Add type checking for feature flags response to ensure it's a valid collection
    type before performing 'in' operation.

    port_ocean/clients/port/mixins/integrations.py [89-90]

    -ORG_USE_PROVISIONED_DEFAULTS_FEATURE_FLAG
    -in (await self.client.get_organization_feature_flags())
    +feature_flags = await self.client.get_organization_feature_flags()
    +isinstance(feature_flags, (list, set, dict)) and
    +ORG_USE_PROVISIONED_DEFAULTS_FEATURE_FLAG in feature_flags
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: Type validation before performing the 'in' operation is important to prevent TypeError exceptions if the API returns unexpected data types, enhancing code robustness.

    Medium
    • Update

    @erikzaadi erikzaadi force-pushed the PORT-12242-ocean-saas-flow-ensure-ff branch from df50730 to 7c4c728 Compare February 23, 2025 10:44
    Copy link

    This pull request is automatically being deployed by Amplify Hosting (learn more).

    Access this pull request here: https://pr-1419.d1ftd8v2gowp8w.amplifyapp.com

    @erikzaadi erikzaadi force-pushed the PORT-12242-ocean-saas-flow-ensure-ff branch from 7c4c728 to 6ef0fb3 Compare February 23, 2025 11:07
    Copy link
    Contributor

    @omby8888 omby8888 left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    @erikzaadi erikzaadi merged commit 257df5b into main Feb 23, 2025
    17 checks passed
    @erikzaadi erikzaadi deleted the PORT-12242-ocean-saas-flow-ensure-ff branch February 23, 2025 11:17
    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