Skip to content

fix: resolve issue in connector dir discovery #603

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

Merged
merged 1 commit into from
Jun 18, 2025

Conversation

aaronsteers
Copy link
Contributor

@aaronsteers aaronsteers commented Jun 18, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection of the Airbyte repository root directory, resulting in more efficient and accurate identification when running related commands.
@Copilot Copilot AI review requested due to automatic review settings June 18, 2025 05:06
@github-actions github-actions bot added bug Something isn't working security labels Jun 18, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the connector directory discovery by ensuring that if the starting directory itself is the Airbyte repository root, it’s immediately returned instead of only checking parent and sibling directories.

  • Added a direct _is_airbyte_repo_root check on current_dir within the traversal loop.
  • Short-circuits and returns current_dir when it matches the repo root.
Copy link
Contributor

coderabbitai bot commented Jun 18, 2025

📝 Walkthrough

Walkthrough

The update modifies the resolve_airbyte_repo_root function to check if the current directory is the Airbyte repository root before searching adjacent directories. This ensures immediate detection and return if the starting or any traversed directory is the repository root.

Changes

File(s) Change Summary
airbyte_cdk/utils/connector_paths.py Enhanced resolve_airbyte_repo_root to check the current directory for repo root before others.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant connector_paths.py

    Caller->>connector_paths.py: resolve_airbyte_repo_root(start_dir)
    connector_paths.py->>connector_paths.py: _is_airbyte_repo_root(current_dir)
    alt If current_dir is repo root
        connector_paths.py-->>Caller: return current_dir
    else
        connector_paths.py->>connector_paths.py: _find_in_adjacent_dirs(current_dir)
        connector_paths.py-->>Caller: return found_dir or None
    end
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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 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
Contributor

@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

🧹 Nitpick comments (1)
airbyte_cdk/utils/connector_paths.py (1)

70-74: Early-return is spot-on; tiny refactor could simplify the loop, wdyt?

Great catch adding the _is_airbyte_repo_root(current_dir) short-circuit – this resolves the “already at repo root” scenario.
For readability (and a microscopic performance gain), you could perform this check once before entering the while loop:

current_dir = from_dir.resolve().absolute()
-while current_dir != current_dir.parent:
-    if _is_airbyte_repo_root(current_dir):
-        return current_dir
+if _is_airbyte_repo_root(current_dir):
+    return current_dir
+
+while current_dir != current_dir.parent:

This avoids re-evaluating the same directory twice on the first iteration and makes the intent crystal-clear.
No functional change, purely stylistic – up to you if you think it reads better, 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 7538d27 and aa37759.

📒 Files selected for processing (1)
  • airbyte_cdk/utils/connector_paths.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Check: source-intercom
  • GitHub Check: Check: source-amplitude
  • GitHub Check: Check: source-pokeapi
  • GitHub Check: Check: source-hardcoded-records
  • GitHub Check: Check: source-shopify
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Analyze (python)
Copy link
Contributor

coderabbitai bot commented Jun 18, 2025

📝 Walkthrough

Walkthrough

The update modifies the internal logic of the resolve_airbyte_repo_root function. It now checks if the current directory is the Airbyte repository root before searching adjacent directories, allowing for an immediate return if the root is found at the current level.

Changes

File(s) Change Summary
airbyte_cdk/utils/connector_paths.py Added a direct check for the Airbyte repo root in the current directory within the main loop.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant resolve_airbyte_repo_root
    participant _is_airbyte_repo_root
    participant _find_in_adjacent_dirs

    Caller->>resolve_airbyte_repo_root: Call function
    loop For each directory up to filesystem root
        resolve_airbyte_repo_root->>_is_airbyte_repo_root: Check if current_dir is repo root
        alt If current_dir is root
            _is_airbyte_repo_root-->>resolve_airbyte_repo_root: True
            resolve_airbyte_repo_root-->>Caller: Return current_dir
        else Not root
            _is_airbyte_repo_root-->>resolve_airbyte_repo_root: False
            resolve_airbyte_repo_root->>_find_in_adjacent_dirs: Search adjacent dirs for repo root
            _find_in_adjacent_dirs-->>resolve_airbyte_repo_root: Return result or None
        end
    end
    resolve_airbyte_repo_root-->>Caller: Return None if not found
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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 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
Contributor

@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

🧹 Nitpick comments (1)
airbyte_cdk/utils/connector_paths.py (1)

34-41: Tiny readability tweak in _is_airbyte_repo_root?

Would dropping the intermediate list and using straightforward boolean operators make this a bit leaner? Something like:

-return all(
-    [
-        (path.name == "airbyte" or path.name == "airbyte-enterprise"),
-        (path / "airbyte-integrations").is_dir(),
-    ]
-)
+return (
+    path.name in {"airbyte", "airbyte-enterprise"}
+    and (path / "airbyte-integrations").is_dir()
+)

Same semantics, one less allocation, and (arguably) easier to read — 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 7538d27 and aa37759.

📒 Files selected for processing (1)
  • airbyte_cdk/utils/connector_paths.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Check: source-intercom
  • GitHub Check: Check: source-amplitude
  • GitHub Check: Check: source-pokeapi
  • GitHub Check: Check: source-hardcoded-records
  • GitHub Check: Check: source-shopify
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: SDM Docker Image Build
🔇 Additional comments (1)
airbyte_cdk/utils/connector_paths.py (1)

72-74: Nice short-circuit!

Checking current_dir first avoids an unneeded _find_in_adjacent_dirs call when we’re already at the repo root — good catch.

Copy link

PyTest Results (Fast)

3 667 tests  ±0   3 656 ✅ ±0   6m 1s ⏱️ +5s
    1 suites ±0      11 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit aa37759. ± Comparison against base commit 7538d27.

Copy link

PyTest Results (Full)

3 670 tests  ±0   3 659 ✅ ±0   17m 40s ⏱️ -3s
    1 suites ±0      11 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit aa37759. ± Comparison against base commit 7538d27.

@aaronsteers aaronsteers merged commit 37cf511 into main Jun 18, 2025
28 checks passed
@aaronsteers aaronsteers deleted the aj/tests/fix-enterprise-root-discovery branch June 18, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working security
1 participant