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

Feat: Add docker image override for connectors in Cloud #420

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

aaronsteers
Copy link
Contributor

@aaronsteers aaronsteers commented Oct 16, 2024

This PR aims to add capability of overriding the docker image used by a connector.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new dataclass for managing Docker image overrides for connectors.
    • Added functionality to retrieve and set Docker image overrides for connectors.
  • Bug Fixes

    • Enhanced error handling for missing keys and multiple overrides in connector image retrieval.
  • Tests

    • Expanded integration tests to cover new functionalities, including testing for valid bearer tokens and connector overrides.

@aaronsteers aaronsteers changed the title WIP (DO NOT MERGE): Ability to override docker image for connector in Cloud Feat (DO NOT MERGE): Override docker image for connector in Cloud Oct 18, 2024
Base automatically changed from aj/feat/cloud-deploy-features-from-experimental to main December 10, 2024 02:48
Copy link

coderabbitai bot commented Dec 10, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request introduces enhancements to Airbyte's API utility module, focusing on Docker image override management for connectors. The changes include a new DockerImageOverride dataclass and two key functions: get_connector_image_override and set_actor_override. These additions provide more granular control over connector image configurations, allowing workspace and actor-level overrides. Corresponding integration tests have been added to validate the new functionality, ensuring robust error handling and correct API interactions.

Changes

File Change Summary
airbyte/_util/api_util.py - Added DockerImageOverride dataclass
- Implemented get_connector_image_override() method
- Implemented set_actor_override() method
- Enhanced with detailed docstrings
tests/integration_tests/cloud/test_cloud_api_util.py - Added test_get_bearer_token() test
- Added test_check_connector() test
- Added test_get_connector_overrides() test
- Updated import statements

Sequence Diagram

sequenceDiagram
    participant User
    participant APIUtil
    participant ConfigAPI
    
    User->>APIUtil: get_connector_image_override()
    APIUtil->>ConfigAPI: Request image override
    ConfigAPI-->>APIUtil: Return override details
    APIUtil-->>User: Return DockerImageOverride or None

    User->>APIUtil: set_actor_override()
    APIUtil->>ConfigAPI: Send override configuration
    ConfigAPI-->>APIUtil: Confirm override set
Loading

Possibly related PRs

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (4)
airbyte/_util/api_util.py (2)

20-20: Consider importing Literal from typing instead of typing_extensions

Should we import Literal directly from the typing module since it's available in Python 3.8+? This could help reduce external dependencies. Wdyt?

🧰 Tools
🪛 Ruff (0.8.0)

20-20: Import from typing instead: Literal

Import from typing

(UP035)


776-776: Add issue links to TODO comments

Could we add issue links to the TODO comments to provide more context and facilitate tracking these tasks? Wdyt?

Also applies to: 780-780, 782-782, 822-822

🧰 Tools
🪛 Ruff (0.8.0)

776-776: Missing issue link on the line following this TODO

(TD003)

airbyte/cloud/workspaces.py (2)

17-17: Unused import of SyncResult

It seems that SyncResult is imported but not used in this file. Should we remove the unused import to keep the code clean? Wdyt?

🧰 Tools
🪛 Ruff (0.8.0)

17-17: airbyte.cloud.sync_results.SyncResult imported but unused

Remove unused import: airbyte.cloud.sync_results.SyncResult

(F401)


25-25: Move Destination import outside of TYPE_CHECKING block

Since Destination is used at runtime and not just for type hinting, should we move its import out of the TYPE_CHECKING block to avoid potential import errors? Wdyt?

🧰 Tools
🪛 Ruff (0.8.0)

25-25: Move import airbyte.destinations.base.Destination out of type-checking block. Import is used for more than type hinting.

Move out of type-checking block

(TC004)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7e65ab3 and 074ffd9.

📒 Files selected for processing (3)
  • airbyte/_util/api_util.py (7 hunks)
  • airbyte/cloud/connections.py (3 hunks)
  • airbyte/cloud/workspaces.py (2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.0)
airbyte/cloud/workspaces.py

17-17: airbyte.cloud.sync_results.SyncResult imported but unused

Remove unused import: airbyte.cloud.sync_results.SyncResult

(F401)


25-25: Move import airbyte.destinations.base.Destination out of type-checking block. Import is used for more than type hinting.

Move out of type-checking block

(TC004)

airbyte/cloud/connections.py

93-93: Redefinition of unused source from line 81

(F811)


124-124: Redefinition of unused destination from line 112

(F811)

airbyte/_util/api_util.py

20-20: Import from typing instead: Literal

Import from typing

(UP035)


776-776: Missing issue link on the line following this TODO

(TD003)


780-780: Missing issue link on the line following this TODO

(TD003)


782-782: Missing issue link on the line following this TODO

(TD003)


822-822: Missing issue link on the line following this TODO

(TD003)

airbyte/_util/api_util.py Outdated Show resolved Hide resolved
airbyte/_util/api_util.py Outdated Show resolved Hide resolved
airbyte/cloud/connections.py Outdated Show resolved Hide resolved
airbyte/cloud/connections.py Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
tests/integration_tests/cloud/test_cloud_api_util.py (1)

249-268: Consider enhancing the test once check_connector is implemented.

The test structure looks good, but it might need additional assertions and test cases once the check_connector function is fully implemented. Would you like me to help draft additional test cases when the implementation is ready?

airbyte/_util/api_util.py (1)

784-828: Consider tracking TODOs with GitHub issues.

The implementation looks good, but there are several TODOs that should be tracked:

  1. Line 805: Fix the config_key
  2. Line 808: Implement get_actor_definition call
  3. Line 810: Determine user ID or alternative origin type

Would you like me to help create GitHub issues for tracking these tasks?

🧰 Tools
🪛 Ruff (0.8.0)

805-805: Missing issue link on the line following this TODO

(TD003)


808-808: Missing issue link on the line following this TODO

(TD003)


810-810: Missing issue link on the line following this TODO

(TD003)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 074ffd9 and 591b09e.

📒 Files selected for processing (2)
  • airbyte/_util/api_util.py (9 hunks)
  • tests/integration_tests/cloud/test_cloud_api_util.py (2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.0)
airbyte/_util/api_util.py

805-805: Missing issue link on the line following this TODO

(TD003)


808-808: Missing issue link on the line following this TODO

(TD003)


810-810: Missing issue link on the line following this TODO

(TD003)


832-832: Unused function argument: actor_id

(ARG001)


833-833: Unused function argument: connector_type

(ARG001)


845-845: Local variable bearer_token is assigned to but never used

Remove assignment to unused variable bearer_token

(F841)


850-850: Undefined name source_id

(F821)


850-850: Undefined name api_key

(F821)


882-882: Missing issue link on the line following this TODO

(TD003)

🔇 Additional comments (6)
tests/integration_tests/cloud/test_cloud_api_util.py (1)

235-246: LGTM! The test looks good.

The test properly validates the token retrieval and handles exceptions appropriately.

airbyte/_util/api_util.py (5)

49-61: LGTM! Well-documented constants.

The API root URLs are clearly defined with helpful documentation links.


744-773: LGTM! The implementation looks secure and robust.

The function properly handles authentication and uses SecretString for sensitive data.


776-781: LGTM! Clean and simple dataclass definition.

The dataclass is well-structured with appropriate type hints.


877-880: ⚠️ Potential issue

Fix the Content-Type header value.

The Content-Type header value should be "application/json" instead of "application".

    headers: dict[str, Any] = {
-        "Content-Type": "application",
+        "Content-Type": "application/json",
        "Authorization": SecretString(f"Bearer {bearer_token}"),
    }

Likely invalid or redundant comment.


881-889: Consider using GET for retrieving configurations.

The function uses POST for listing configurations. While this might be intentional based on the API design, typically GET is used for retrieving data. Could you confirm if this aligns with the API documentation? Wdyt?

🧰 Tools
🪛 Ruff (0.8.0)

882-882: Missing issue link on the line following this TODO

(TD003)

airbyte/_util/api_util.py Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (2)
tests/integration_tests/cloud/test_cloud_api_util.py (1)

236-247: Consider enhancing test coverage

The test verifies basic token retrieval, but we could make it more robust. Would you like to add assertions for:

  • Token format (should be a non-empty string)
  • Error cases (invalid credentials)
  • Token expiration handling
    wdyt?
airbyte/_util/api_util.py (1)

776-833: Enhance function documentation and type hints

The implementation looks good, but a few suggestions:

  1. Add return value documentation in the docstring
  2. Consider using a TypedDict or dataclass for the response structure instead of tuple
  3. Add examples in the docstring
    wdyt?
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 591b09e and a21cf57.

📒 Files selected for processing (2)
  • airbyte/_util/api_util.py (9 hunks)
  • tests/integration_tests/cloud/test_cloud_api_util.py (2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.0)
airbyte/_util/api_util.py

870-870: Missing issue link on the line following this TODO

(TD003)


873-873: Missing issue link on the line following this TODO

(TD003)


875-875: Missing issue link on the line following this TODO

(TD003)


923-923: Missing issue link on the line following this TODO

(TD003)

🔇 Additional comments (2)
airbyte/_util/api_util.py (2)

835-893: ⚠️ Potential issue

Address TODOs and security considerations

Several items need attention:

  1. The TODOs need to be addressed with proper implementation:
    • Line 870: Fix config_key
    • Line 873: Implement get_actor_definition
    • Line 875: Handle user ID or origin type
  2. The Authorization header contains a bearer token wrapped in SecretString, but it's converted to string in the f-string, potentially exposing it in logs
    wdyt?
🧰 Tools
🪛 Ruff (0.8.0)

870-870: Missing issue link on the line following this TODO

(TD003)


873-873: Missing issue link on the line following this TODO

(TD003)


875-875: Missing issue link on the line following this TODO

(TD003)


895-956: ⚠️ Potential issue

Fix API request issues and improve error handling

Several issues need attention:

  1. The Content-Type header value is incorrect:
     headers: dict[str, Any] = {
-        "Content-Type": "application",
+        "Content-Type": "application/json",
         "Authorization": SecretString(f"Bearer {bearer_token}"),
     }
  1. Using POST for a read operation seems unusual. Should we consider using GET? wdyt?
  2. The TODO for config_key needs to be addressed
  3. Consider adding pagination handling for the list of overrides

Likely invalid or redundant comment.

🧰 Tools
🪛 Ruff (0.8.0)

923-923: Missing issue link on the line following this TODO

(TD003)

tests/integration_tests/cloud/test_cloud_api_util.py Outdated Show resolved Hide resolved
tests/integration_tests/cloud/test_cloud_api_util.py Outdated Show resolved Hide resolved
airbyte/_util/api_util.py Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
tests/integration_tests/cloud/test_cloud_api_util.py (1)

240-261: Consider enhancing token validation test cases

The current test validates basic token retrieval, but we could make it more robust. What do you think about adding:

  1. Token format validation (JWT structure)
  2. Negative test cases (invalid credentials)
  3. Timeout handling for API calls
    wdyt?
@pytest.mark.parametrize(
    "client_id, client_secret, api_root, expected_exception",
    [
        (airbyte_cloud_client_id, airbyte_cloud_client_secret, CLOUD_API_ROOT, None),
        ("invalid_id", "invalid_secret", CLOUD_API_ROOT, AirbyteError),
        # Add more test cases
    ],
)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a21cf57 and 544829c.

📒 Files selected for processing (1)
  • tests/integration_tests/cloud/test_cloud_api_util.py (2 hunks)
🔇 Additional comments (2)
tests/integration_tests/cloud/test_cloud_api_util.py (2)

263-289: Enhance error handling assertions

Building upon the previous feedback about test coverage, I noticed we're not asserting the content of error_message. Since we're capturing it in the response, should we add assertions to validate error scenarios? For example:

  1. Assert specific error messages for invalid connector IDs
  2. Validate error format and content
    wdyt?

291-310: 🛠️ Refactor suggestion

Consider improving test isolation

The test uses a hardcoded actor_id which could cause issues. What if we:

  1. Create a temporary connector for testing
  2. Add proper teardown to clean up test data
  3. Use pytest fixtures for test data setup
    wdyt?

Example approach:

@pytest.fixture
def test_connector():
    # Setup: Create temporary connector
    connector = create_test_connector()
    yield connector
    # Teardown: Clean up
    delete_test_connector(connector.id)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
airbyte/_util/api_util.py (1)

874-880: Consider linking TODOs to GitHub issues

There are several TODO comments without corresponding issue links. Would you like me to help create GitHub issues for tracking these tasks?

🧰 Tools
🪛 Ruff (0.8.0)

874-874: Missing issue link on the line following this TODO

(TD003)


877-877: Missing issue link on the line following this TODO

(TD003)


879-879: Missing issue link on the line following this TODO

(TD003)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 544829c and 6cebe55.

📒 Files selected for processing (2)
  • airbyte/_util/api_util.py (9 hunks)
  • tests/integration_tests/cloud/test_cloud_api_util.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/integration_tests/cloud/test_cloud_api_util.py
🧰 Additional context used
🪛 Ruff (0.8.0)
airbyte/_util/api_util.py

874-874: Missing issue link on the line following this TODO

(TD003)


877-877: Missing issue link on the line following this TODO

(TD003)


879-879: Missing issue link on the line following this TODO

(TD003)


927-927: Missing issue link on the line following this TODO

(TD003)

🔇 Additional comments (5)
airbyte/_util/api_util.py (5)

49-61: LGTM! Well-documented API constants.

The API root constants are well-defined with comprehensive docstrings and helpful documentation links.


756-759: Consider updating the Content-Type header

The Content-Type header should be "application/json" for JSON payloads. Wdyt?

     headers: dict[str, str] = {
-        "content-type": "application/json",
+        "Content-Type": "application/json",
         "accept": "application/json",
     }

929-934: Consider using GET request for listing configurations

HTTP GET is more appropriate for retrieving data. The current implementation uses POST with a request body, which some clients might ignore. Should we change this to use query parameters with a GET request? Wdyt?


888-896: LGTM! Comprehensive error handling.

The error handling is thorough and consistent, providing good context in error messages.

Also applies to: 935-943


922-925: ⚠️ Potential issue

Fix Content-Type header value

The Content-Type header value should be "application/json". Wdyt?

     headers: dict[str, Any] = {
-        "Content-Type": "application",
+        "Content-Type": "application/json",
         "Authorization": SecretString(f"Bearer {bearer_token}"),
     }

Likely invalid or redundant comment.

@aaronsteers aaronsteers changed the title Feat (DO NOT MERGE): Override docker image for connector in Cloud Feat (DO NOT MERGE): Add check connection feature and docker image override for connectors in Cloud Dec 11, 2024
@aaronsteers aaronsteers changed the title Feat (DO NOT MERGE): Add check connection feature and docker image override for connectors in Cloud Feat: Add check connection feature and docker image override for connectors in Cloud Dec 11, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (4)
tests/integration_tests/cloud/test_cloud_api_util.py (2)

247-260: Enhance token validation in the test

The test verifies that the token is not None, but we could make it more robust. Consider:

  1. Adding assertions to verify the token format (e.g., JWT structure)
  2. Testing with invalid credentials to verify error handling
  3. Adding a timeout parameter to prevent hanging on network issues
    wdyt?

Line range hint 824-826: Remove debug print statements

These debug print statements should be removed before merging:

print(f"URL: {prepared.url}")
print(f"Headers: {prepared.headers}")
print(f"Body: {prepared.body}")

Consider replacing them with proper logging if the information is valuable for debugging.

🧰 Tools
🪛 Ruff (0.8.2)

18-18: airbyte._util.api_util.CLOUD_CONFIG_API_ROOT imported but unused

Remove unused import: airbyte._util.api_util.CLOUD_CONFIG_API_ROOT

(F401)

airbyte/_util/api_util.py (2)

837-845: Improve error handling and remove debug TODOs

The error handling includes debug information that should be cleaned up:

  1. Remove the "TODO: Remove extra debug prints" comment
  2. Consider structuring the error context more cleanly
  3. Add proper logging instead of debug prints
    wdyt?
🧰 Tools
🪛 Ruff (0.8.2)

837-837: Missing issue link on the line following this TODO

(TD003)


988-992: Document multiple overrides limitation

The function raises NotImplementedError for multiple overrides. Consider:

  1. Adding this limitation to the function's docstring
  2. Creating a tracking issue for supporting multiple overrides
  3. Specifying which override would be preferred when support is added (e.g., most recent, workspace level over actor level)
    wdyt?
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6cebe55 and 0d600f8.

📒 Files selected for processing (2)
  • airbyte/_util/api_util.py (9 hunks)
  • tests/integration_tests/cloud/test_cloud_api_util.py (2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
tests/integration_tests/cloud/test_cloud_api_util.py

18-18: airbyte._util.api_util.CLOUD_CONFIG_API_ROOT imported but unused

Remove unused import: airbyte._util.api_util.CLOUD_CONFIG_API_ROOT

(F401)

airbyte/_util/api_util.py

837-837: Missing issue link on the line following this TODO

(TD003)


900-900: Missing issue link on the line following this TODO

(TD003)


903-903: Missing issue link on the line following this TODO

(TD003)


905-905: Missing issue link on the line following this TODO

(TD003)


956-956: Missing issue link on the line following this TODO

(TD003)

🔇 Additional comments (2)
tests/integration_tests/cloud/test_cloud_api_util.py (1)

241-269: Consider expanding test coverage with additional test cases

The parameterized test currently has only one active test case. Would you consider adding:

  1. A test case for destination connectors (uncomment and update the commented test case)
  2. A test case for invalid connector IDs to verify error handling
  3. A test case for expired/invalid credentials
    wdyt?
airbyte/_util/api_util.py (1)

949-954: ⚠️ Potential issue

Fix HTTP headers and request method

Several issues with the request headers:

  1. Content-Type should be "application/json" instead of "application"
  2. Setting headers to None is unusual, consider removing these lines:
-        "Connection": None,
-        "User-Agent": None,
  1. Consider using GET method without a request body as per HTTP standards
    wdyt?

Likely invalid or redundant comment.

airbyte/_util/api_util.py Outdated Show resolved Hide resolved
airbyte/_util/api_util.py Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
airbyte/_util/api_util.py (1)

771-775: ⚠️ Potential issue

Include grant_type parameter in OAuth 2.0 token request

In the get_bearer_token function, should we include the grant_type parameter set to 'client_credentials' in the request body to comply with the OAuth 2.0 specification? Wdyt?

🧹 Nitpick comments (6)
airbyte/cloud/connectors.py (2)

39-45: Update __repr__ method to reflect the correct class name

In the __repr__ method of CheckResult, the class name is displayed as CloudCheckResult, but the actual class name is CheckResult. Should we update the string to match the class name? Wdyt?


103-104: Consider raising a more specific exception for check failures

Currently, we're raising a ValueError when the check fails. Would it be better to raise a more specific exception, perhaps a custom exception like AirbyteCheckError, to provide clearer context? Wdyt?

airbyte/_util/api_util.py (4)

894-894: Add issue link to TODO comment on line 894

There's a TODO comment on line 894 without an associated issue link. Could we add an issue link to track this task? Wdyt?

🧰 Tools
🪛 Ruff (0.8.2)

894-894: Missing issue link on the line following this TODO

(TD003)


950-950: Add issue link to TODO comment on line 950

The TODO comment on line 950 is missing an issue link. Adding one would help in managing pending tasks. Wdyt?

🧰 Tools
🪛 Ruff (0.8.2)

950-950: Missing issue link on the line following this TODO

(TD003)


953-953: Add issue link to TODO comment on line 953

Line 953 contains a TODO comment without an issue link. Should we include an issue link for better tracking? Wdyt?

🧰 Tools
🪛 Ruff (0.8.2)

953-953: Missing issue link on the line following this TODO

(TD003)


955-955: Add issue link to TODO comment on line 955

The TODO comment on line 955 lacks an associated issue link. Adding one could improve task management. Wdyt?

🧰 Tools
🪛 Ruff (0.8.2)

955-955: Missing issue link on the line following this TODO

(TD003)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d600f8 and 4002a73.

📒 Files selected for processing (3)
  • airbyte/_util/api_util.py (9 hunks)
  • airbyte/cloud/connectors.py (2 hunks)
  • tests/integration_tests/cloud/test_cloud_api_util.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/integration_tests/cloud/test_cloud_api_util.py
🧰 Additional context used
🪛 Ruff (0.8.2)
airbyte/_util/api_util.py

894-894: Missing issue link on the line following this TODO

(TD003)


950-950: Missing issue link on the line following this TODO

(TD003)


953-953: Missing issue link on the line following this TODO

(TD003)


955-955: Missing issue link on the line following this TODO

(TD003)

@aaronsteers aaronsteers changed the title Feat: Add check connection feature and docker image override for connectors in Cloud Feat: Add docker image override for connectors in Cloud Dec 17, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
airbyte/_util/api_util.py (3)

890-893: Confirm the correctness of 'config_key' and resolve TODO

The config_key is currently set to "docker_image" with a TODO comment to fix it. Should we verify if "docker_image" is the correct key or update it accordingly? This might prevent potential issues when making the API request. Wdyt?

🧰 Tools
🪛 Ruff (0.8.2)

892-892: Missing issue link on the line following this TODO

(TD003)


911-916: Consider adding error handling for missing keys in 'entry'

When constructing the overrides list, the code assumes that each entry in scoped_configurations contains the keys "value" and "scope_type". Would it be beneficial to add error handling or validation to ensure these keys exist in each entry, preventing possible KeyError exceptions? Wdyt?


918-924: Implement support for multiple overrides or clarify the limitation

Currently, if multiple overrides are found (len(overrides) > 1), a NotImplementedError is raised stating that this is not yet supported. Should we consider implementing support for multiple overrides or provide more detailed guidance on this limitation to inform users? Wdyt?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4002a73 and 93acdcc.

📒 Files selected for processing (1)
  • airbyte/_util/api_util.py (2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
airbyte/_util/api_util.py

892-892: Missing issue link on the line following this TODO

(TD003)


948-948: Missing issue link on the line following this TODO

(TD003)


951-951: Missing issue link on the line following this TODO

(TD003)


953-953: Missing issue link on the line following this TODO

(TD003)

🔇 Additional comments (3)
airbyte/_util/api_util.py (3)

17-17: Importing 'dataclass' is appropriate

Importing dataclass from the dataclasses module is necessary for defining the DockerImageOverride dataclass below.


864-870: 'DockerImageOverride' dataclass is well-defined

The DockerImageOverride dataclass appropriately encapsulates the docker image override details, including the docker_image_override and override_level fields.


948-949: Address TODO comments and placeholders

There are several TODO comments and placeholder values that may need attention:

  • Line 948: "config_key": "docker_image", # TODO: Fix this.
  • Line 951: "resource_id": "", # TODO: Need to call something like get_actor_definition
  • Line 953: "origin": "", # TODO: Need to get user ID somehow or use another origin type

Would it be helpful to resolve these TODOs or add issue links to track them for future implementation? I'm happy to assist if needed. Wdyt?

Also applies to: 951-955

🧰 Tools
🪛 Ruff (0.8.2)

948-948: Missing issue link on the line following this TODO

(TD003)

airbyte/_util/api_util.py Outdated Show resolved Hide resolved
@aaronsteers
Copy link
Contributor Author

/format-fix

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
airbyte/_util/api_util.py (1)

892-909: Consider enhancing error handling and TODO tracking.

A few suggestions to improve this section:

  1. The TODO comment needs tracking. Would you like me to create a GitHub issue for this?
  2. Consider adding type hints for the json_result dictionary to improve type safety.
  3. The error message could be more descriptive by including the actual response content.

Here's a suggested improvement:

    json_result = _make_config_api_request(
        path="/scoped_configuration/list",
        json={
-            "config_key": "docker_image",  # TODO: Fix this.
+            "config_key": "docker_image",  # TODO(#issue): Update config_key based on API requirements
        },
        api_root=api_root,
        client_id=client_id,
        client_secret=client_secret,
    )
    try:
        scoped_configurations = json_result["scopedConfigurations"]
    except KeyError as ex:
        raise AirbyteError(
            message="Could not find 'scoped_configurations' in response.",
            context={
                "workspace_id": workspace_id,
                "actor_id": actor_id,
                "actor_type": actor_type,
                "response_keys": list(json_result.keys()),
+               "response_content": json_result,  # Add actual response for better debugging
            },
        ) from ex

wdyt?

🧰 Tools
🪛 Ruff (0.8.2)

892-892: Missing issue link on the line following this TODO

(TD003)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93acdcc and a59d13f.

📒 Files selected for processing (1)
  • airbyte/_util/api_util.py (2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
airbyte/_util/api_util.py

892-892: Missing issue link on the line following this TODO

(TD003)


948-948: Missing issue link on the line following this TODO

(TD003)


951-951: Missing issue link on the line following this TODO

(TD003)


953-953: Missing issue link on the line following this TODO

(TD003)

🔇 Additional comments (2)
airbyte/_util/api_util.py (2)

864-870: LGTM! Well-structured dataclass.

The DockerImageOverride dataclass is clean, well-documented, and follows best practices with appropriate type hints.


872-925: LGTM! Robust implementation with good error handling.

The function is well-structured with comprehensive error handling and clear documentation.

🧰 Tools
🪛 Ruff (0.8.2)

892-892: Missing issue link on the line following this TODO

(TD003)

airbyte/_util/api_util.py Show resolved Hide resolved
Comment on lines +947 to +954
"value": override.docker_image_override,
"config_key": "docker_image", # TODO: Fix this.
"scope_id": actor_id,
"scope_type": actor_type,
"resource_id": "", # TODO: Need to call something like get_actor_definition
"resource_type": "ACTOR_DEFINITION",
"origin": "", # TODO: Need to get user ID somehow or use another origin type
"origin_type": "USER",
Copy link
Contributor Author

@aaronsteers aaronsteers Dec 19, 2024

Choose a reason for hiding this comment

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

These are placeholders and probably wrong.

For instance, "config_key": "docker_image" is psuedocode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant