Skip to content

fix(executors): discover connector console script from entry points#1071

Open
SIV HARI NAIR (sivharinair2001) wants to merge 1 commit into
airbytehq:mainfrom
sivharinair2001:sivharinair2001/fix-issue-290-executable-discovery
Open

fix(executors): discover connector console script from entry points#1071
SIV HARI NAIR (sivharinair2001) wants to merge 1 commit into
airbytehq:mainfrom
sivharinair2001:sivharinair2001/fix-issue-290-executable-discovery

Conversation

@sivharinair2001

@sivharinair2001 SIV HARI NAIR (sivharinair2001) commented Jul 10, 2026

Copy link
Copy Markdown

VenvExecutor no longer assumes the installed CLI name matches the connector name. When they differ, resolve the executable via console_scripts metadata instead of triggering a useless reinstall loop.

Closes #290

Summary by CodeRabbit

  • Bug Fixes

    • Improved connector installation to correctly detect and use the executable registered by the installed package, even when its name differs from the connector name.
    • Improved installation validation and error reporting when an executable cannot be found.
  • Tests

    • Added regression coverage for connectors with mismatched package and console-script names.
    • Added a reproducible verification script for this installation scenario.

VenvExecutor no longer assumes the installed CLI name matches the connector
name. When they differ, resolve the executable via console_scripts metadata
instead of triggering a useless reinstall loop.

Closes airbytehq#290

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the community PRs from community contributors label Jul 10, 2026
@octavia-bot octavia-bot Bot marked this pull request as draft July 10, 2026 07:00
@octavia-bot

octavia-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

Note

📝 PR Converted to Draft

More info...

Thank you for creating this PR. As a policy to protect our engineers' time, Airbyte requires all PRs to be created first in draft status. Your PR has been automatically converted to draft status in respect for this policy.

As soon as your PR is ready for formal review, you can proceed to convert the PR to "ready for review" status by clicking the "Ready for review" button at the bottom of the PR page.

To skip draft status in future PRs, please include [ready] in your PR title or add the skip-draft-status label when creating your PR.

@github-actions

Copy link
Copy Markdown

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

💡 Show Tips and Tricks

Testing This PyAirbyte Version

You can test this version of PyAirbyte using the following:

# Run PyAirbyte CLI from this branch:
uvx --from 'git+https://github.com/airbytehq/PyAirbyte.git@sivharinair2001/fix-issue-290-executable-discovery' pyairbyte --help

# Install PyAirbyte from this branch for development:
pip install 'git+https://github.com/airbytehq/PyAirbyte.git@sivharinair2001/fix-issue-290-executable-discovery'

PR Slash Commands

Airbyte Maintainers can execute the following slash commands on your PR:

  • /fix-pr - Fixes most formatting and linting issues
  • /uv-lock - Updates uv.lock file
  • /test-pr - Runs tests with the updated PyAirbyte
  • /prerelease - Builds and publishes a prerelease version to PyPI
📚 Show Repo Guidance

Helpful Resources

Community Support

Questions? Join the #pyairbyte channel in our Slack workspace.

📝 Edit this welcome message.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

VenvExecutor now discovers a connector’s installed console-script name from package metadata, caches and resets that value across installation lifecycle events, and uses it for executable paths and installation validation. A mismatched-name fixture, regression test, and reproduction script verify the behavior.

Changes

Console Script Resolution

Layer / File(s) Summary
Mismatched executable fixture
tests/integration_tests/fixtures/source-wrong-exe/*
Defines a connector package whose wrong-script-name console script points to the fixture entrypoint and emits a sample specification.
Executable discovery and cache
airbyte/_executors/python.py
Adds PyPI package-name and console-script discovery helpers, uses the resolved name for connector paths, centralizes version lookup, and resets the cached name during installation lifecycle changes.
Installation validation and regression coverage
airbyte/_executors/python.py, tests/unit_tests/test_issue_290_wrong_executable.py, scripts/reproduce_issue_290.py
Validates installation through console-script resolution, includes discovered scripts in failure context, and checks that the mismatched fixture resolves to wrong-script-name.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant VenvExecutor
  participant PackageMetadata
  participant VirtualEnvironment
  VenvExecutor->>PackageMetadata: discover installed console scripts
  PackageMetadata-->>VenvExecutor: return wrong-script-name
  VenvExecutor->>VirtualEnvironment: compute resolved executable path
  VenvExecutor->>VirtualEnvironment: validate resolved executable
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code and regression test address #290 by discovering the real console script after install.
Out of Scope Changes check ✅ Passed The added fixture and reproduction script support the regression fix and are within scope.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: VenvExecutor now discovers connector console scripts from entry points instead of assuming the connector name.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
airbyte/_executors/python.py (3)

358-362: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

The reinstall log message still references self.name instead of the resolved script name — could this be misleading?

Since the entire purpose of this PR is that the executable name may differ from self.name, the log message f"at {get_bin_dir(self._get_venv_path()) / self.name!s}" will show the wrong path when the names differ. Would it be clearer to show the actual bin directory or the resolved name, wdyt?

♻️ Proposed fix
             print(
                 "Connector executable not found within the virtual environment "
-                f"at {get_bin_dir(self._get_venv_path()) / self.name!s}.\nReinstalling...",
+                f"in {get_bin_dir(self._get_venv_path())!s}.\nReinstalling...",
                 file=sys.stderr,
             )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airbyte/_executors/python.py` around lines 358 - 362, Update the reinstall
warning in the relevant executor logic to reference the resolved
executable/script name rather than self.name. Use the same resolved-name
variable used when locating the connector executable, while retaining the bin
directory context in the displayed path.

104-107: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

The elif len(entry_points) == 1 branch is redundant — could we simplify?

Both the elif len(entry_points) == 1 and elif entry_points branches print entry_points[0].name, so the first branch is dead code. The single-entry-point case is already covered by the elif entry_points fallback. Would you consider collapsing these into a single branch, wdyt?

♻️ Proposed simplification
 if connector_name in {{ep.name for ep in entry_points}}:
     print(connector_name)
-elif len(entry_points) == 1:
-    print(entry_points[0].name)
 elif entry_points:
     print(entry_points[0].name)
 else:
     print("")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airbyte/_executors/python.py` around lines 104 - 107, Remove the redundant
`elif len(entry_points) == 1` branch and retain a single `elif entry_points`
branch that prints `entry_points[0].name`, preserving the existing behavior for
one or more entry points.

369-377: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Should discovered_console_scripts in the error context be more informative?

When this error is reached, _resolve_console_script_name() has already returned None twice (before and after reinstall), meaning both the default path check and _discover_console_script_name() failed. Calling _discover_console_script_name() again at line 375 will likely return None again, making the discovered_console_scripts context field always None. Would it be worth listing all console scripts in the venv's bin directory instead, or adjusting the field name to reflect that it may be None, wdyt?

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airbyte/_executors/python.py` around lines 369 - 377, Make the installation
error context informative by avoiding the redundant
_discover_console_script_name() call after _resolve_console_script_name() has
already failed. Update the discovered_console_scripts field to capture and list
the console scripts present in the virtual environment’s bin directory, or
rename it to accurately describe the nullable resolution result, using the
relevant helper methods in the connector installation flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@airbyte/_executors/python.py`:
- Around line 358-362: Update the reinstall warning in the relevant executor
logic to reference the resolved executable/script name rather than self.name.
Use the same resolved-name variable used when locating the connector executable,
while retaining the bin directory context in the displayed path.
- Around line 104-107: Remove the redundant `elif len(entry_points) == 1` branch
and retain a single `elif entry_points` branch that prints
`entry_points[0].name`, preserving the existing behavior for one or more entry
points.
- Around line 369-377: Make the installation error context informative by
avoiding the redundant _discover_console_script_name() call after
_resolve_console_script_name() has already failed. Update the
discovered_console_scripts field to capture and list the console scripts present
in the virtual environment’s bin directory, or rename it to accurately describe
the nullable resolution result, using the relevant helper methods in the
connector installation flow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cb535d68-b380-484c-b62d-e790b3c0e899

📥 Commits

Reviewing files that changed from the base of the PR and between 15ca9ab and c050055.

📒 Files selected for processing (6)
  • airbyte/_executors/python.py
  • scripts/reproduce_issue_290.py
  • tests/integration_tests/fixtures/source-wrong-exe/setup.py
  • tests/integration_tests/fixtures/source-wrong-exe/source_wrong_exe/__init__.py
  • tests/integration_tests/fixtures/source-wrong-exe/source_wrong_exe/run.py
  • tests/unit_tests/test_issue_290_wrong_executable.py

@sivharinair2001 SIV HARI NAIR (sivharinair2001) marked this pull request as ready for review July 10, 2026 07:14
@sivharinair2001 SIV HARI NAIR (sivharinair2001) marked this pull request as draft July 10, 2026 07:14
@sivharinair2001 SIV HARI NAIR (sivharinair2001) marked this pull request as ready for review July 10, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community PRs from community contributors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VenvExecutor fails to install a connector package if it has the wrong executable name

2 participants