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] Added base_url to core #1411

Merged
merged 4 commits into from
Feb 19, 2025
Merged

Conversation

matan84
Copy link
Member

@matan84 matan84 commented Feb 19, 2025

User description

Description

What - Added a new base_url variable to core

Why - allow us to deprecate the app_host usage and to standardize naming to core

How - added new variable to ocean config

Type of change

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • New Integration (non-breaking change which adds a new integration)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Non-breaking change (fix of existing functionality that will not change current behavior)
  • Documentation (added/updated documentation)

All tests should be run against the port production environment(using a testing org).

Core testing checklist

  • Integration able to create all default resources from scratch
  • Resync finishes successfully
  • Resync able to create entities
  • Resync able to update entities
  • Resync able to detect and delete entities
  • Scheduled resync able to abort existing resync and start a new one
  • Tested with at least 2 integrations from scratch
  • Tested with Kafka and Polling event listeners
  • Tested deletion of entities that don't pass the selector

Integration testing checklist

  • Integration able to create all default resources from scratch
  • Resync able to create entities
  • Resync able to update entities
  • Resync able to detect and delete entities
  • Resync finishes successfully
  • If new resource kind is added or updated in the integration, add example raw data, mapping and expected result to the examples folder in the integration directory.
  • If resource kind is updated, run the integration with the example data and check if the expected result is achieved
  • If new resource kind is added or updated, validate that live-events for that resource are working as expected
  • Docs PR link here

Preflight checklist

  • Handled rate limiting
  • Handled pagination
  • Implemented the code in async
  • Support Multi account

Screenshots

Include screenshots from your environment showing how the resources of the integration will look.

API Documentation

Provide links to the API documentation used for this integration.


PR Type

Enhancement


Description

  • Introduced webhook_base_url to replace app_host.

  • Added deprecation warning for app_host usage.

  • Updated lifecycle logic to conditionally start webhook processing.

  • Updated version and changelog to reflect changes.


Changes walkthrough 📝

Relevant files
Enhancement
settings.py
Added `webhook_base_url` configuration field                         

port_ocean/config/settings.py

  • Added webhook_base_url as a new configuration field.
+1/-0     
ocean.py
Added `webhook_base_url` property and lifecycle updates   

port_ocean/ocean.py

  • Implemented webhook_base_url property with fallback to app_host.
  • Added deprecation warning for app_host usage.
  • Modified lifecycle to conditionally start webhook processing.
  • +13/-1   
    Documentation
    CHANGELOG.md
    Updated changelog for version 0.19.3                                         

    CHANGELOG.md

    • Documented addition of webhook_base_url in version 0.19.3.
    +6/-0     
    Configuration changes
    pyproject.toml
    Updated project version to 0.19.3                                               

    pyproject.toml

    • Bumped version to 0.19.3.
    +1/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @matan84 matan84 requested a review from a team as a code owner February 19, 2025 13:04
    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 webhook_base_url property accesses dictionary values without proper error handling for missing keys or type mismatches

    if integration_config.get("app_host"):
        logger.warning(
            "The OCEAN__INTEGRATION__CONFIG__APP_HOST field is deprecated. Please use the OCEAN__WEBHOOK_BASE_URL field instead."
        )
    return self.config.webhook_base_url or integration_config.get("app_host")
    Conditional Logic

    The webhook manager is only started if webhook_base_url exists, which could break existing functionality that depends on webhook processing

    if self.webhook_base_url:
        await self.webhook_manager.start_processing_event_messages()

    Copy link
    Contributor

    qodo-merge-pro bot commented Feb 19, 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
    Validate webhook URL format

    Add error handling for invalid webhook URLs to prevent runtime issues. Validate
    the URL format before using it.

    port_ocean/ocean.py [121-130]

     @property
     def webhook_base_url(self) -> str:
         integration_config = self.config.integration.config
         if isinstance(integration_config, BaseModel):
             integration_config = integration_config.dict()
         if integration_config.get("app_host"):
             logger.warning(
                 "The OCEAN__INTEGRATION__CONFIG__APP_HOST field is deprecated. Please use the OCEAN__WEBHOOK_BASE_URL field instead."
             )
    -    return self.config.webhook_base_url or integration_config.get("app_host")
    +    url = self.config.webhook_base_url or integration_config.get("app_host")
    +    if url and not url.startswith(('http://', 'https://')):
    +        raise ValueError(f"Invalid webhook URL format: {url}")
    +    return url
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    __

    Why: The suggestion adds crucial URL validation to prevent runtime issues with malformed webhook URLs. This is important for system reliability and early error detection, as invalid URLs could cause failures in webhook processing.

    Medium
    • Update

    Copy link

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

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

    Copy link
    Contributor

    @yaelibarg yaelibarg left a comment

    Choose a reason for hiding this comment

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

    @matan84 matan84 changed the title [Core] Added webhook_base_url to core [Core] Added base_url to core Feb 19, 2025
    @matan84 matan84 merged commit bf41c70 into main Feb 19, 2025
    19 checks passed
    @matan84 matan84 deleted the migrate-app-host-to-webhook-base-url branch February 19, 2025 13:27
    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.

    3 participants