Skip to content

Conversation

@aaronsteers
Copy link
Contributor

@aaronsteers aaronsteers commented Dec 2, 2025

Summary

Adds targeted error handling to cloud integration tests that fail when the shared CI workspace contains destinations with stale/deleted secret references. When the Airbyte Cloud API returns a 500 error with "Secret reference ... does not exist", the tests now skip with an informative message instead of failing.

This is a workaround for an infrastructure issue in the CI workspace, not a code bug. The affected tests are:

  • test_list_destinations in test_cloud_api_util.py
  • test_deploy_destination in test_cloud_workspaces.py

Both tests call list_destinations (directly or indirectly via deploy_destination), which paginates through all destinations in the workspace and fails when it encounters one with a broken secret reference.

Review & Testing Checklist for Human

  • Verify the error matching (status_code == 500 AND "Secret reference" in message) is specific enough to not accidentally mask unrelated API errors
  • Consider whether the duplicated STALE_SECRET_REFERENCE_ERROR constant should be extracted to a shared test utilities module
  • Create a tech debt issue to track cleanup of the stale destinations in the CI workspace (workspace ID: 19d7a891-8e0e-40ac-8a8c-5faf8d11e47c)

Test plan: Wait for CI to pass. The previously failing tests should now either pass (if the workspace is clean) or skip (if stale secrets are still present).

Notes

Summary by CodeRabbit

  • Tests
    • Improved integration test reliability by adding error handling for known CI infrastructure edge cases, preventing false test failures.

✏️ Tip: You can customize this high-level summary in your review settings.

… tests

The shared CI workspace contains destinations with deleted/stale secret
references, causing the Airbyte Cloud API to return 500 errors when
listing destinations. This is an infrastructure issue, not a code bug.

This fix adds targeted error handling to catch the specific SDKError
with status 500 and 'Secret reference' in the message, and skips the
test with an informative message instead of failing.

Affected tests:
- test_list_destinations (test_cloud_api_util.py)
- test_deploy_destination (test_cloud_workspaces.py)

Co-Authored-By: AJ Steers <aj@airbyte.io>
@devin-ai-integration
Copy link
Contributor

Original prompt from AJ Steers
SYSTEM:
=== BEGIN THREAD HISTORY (in #hydra-pyairbyte-mcp) ===
Aldo Alberto Jesus Gonzalez Campos (U070BMPDUHJ): :octavia-hello: Is the <https://airbytehq.github.io/PyAirbyte/airbyte/mcp.html#getting-started-with-pyairbyte-mcp|pyairbyte-mcp> the one we address as coral-mcp?

AJ Steers (U05AKF1BCC9): Yes, that's correct.

AJ Steers (U05AKF1BCC9): Do you want install/setup instructions? I can link you to those docs if helpful.

AJ Steers (U05AKF1BCC9): Essentially `uvx --from=airbyte airbyte-mcp`

AJ Steers (U05AKF1BCC9): Btw, are we ever going to use "Coral" as a user-facing dilineation? (Rhetorical, no answer needed. :sweat_smile: )

Aldo Alberto Jesus Gonzalez Campos (U070BMPDUHJ): &gt;  Essentially `uvx --from=airbyte airbyte-mcp`
Link would be cool anyway

Aldo Alberto Jesus Gonzalez Campos (U070BMPDUHJ): Also, what is the repo this mcp?

Aldo Alberto Jesus Gonzalez Campos (U070BMPDUHJ): Oh wait, is it part of <https://github.com/airbytehq/PyAirbyte/tree/main/airbyte/mcp|pyaribyte> repo?

AJ Steers (U05AKF1BCC9): Yes, that's correct.

AJ Steers (U05AKF1BCC9): <https://airbytehq.github.io/PyAirbyte/airbyte/mcp.html|https://airbytehq.github.io/PyAirbyte/airbyte/mcp.html>

AJ Steers (U05AKF1BCC9): <@U070BMPDUHJ> - Did you get what you needed here?

Aldo Alberto Jesus Gonzalez Campos (U070BMPDUHJ): Got distracted with something else, let me check if I can achieve the bare minimum of having pyairbyte mcp running with claude for my test org

AJ Steers (U05AKF1BCC9): It should work for most/all use cases. Please let me know if you run into issues, as that feedback will help make it better for the next person. :thanks-keanu:

Aldo Alberto Jesus Gonzalez Campos (U070BMPDUHJ): I don't understand this var `AIRBYTE_PROJECT_DIR`:
~/.mcp/airbyte_mcp.env
```# Airbyte Project Artifacts Directory
AIRBYTE_PROJECT_DIR=/path/to/any/writeable/project-dir```
Should that point to a local airbyte repo, PyAirbyte repo, or something else?

Aldo Alberto Jesus Gonzalez Campos (U070BMPDUHJ):... (8552 chars truncated...)

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

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@devin/1764662151-fix-cloud-test-secret-reference' pyairbyte --help

# Install PyAirbyte from this branch for development:
pip install 'git+https://github.com/airbytehq/PyAirbyte.git@devin/1764662151-fix-cloud-test-secret-reference'

Helpful Resources

PR Slash Commands

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

  • /fix-pr - Fixes most formatting and linting issues
  • /poetry-lock - Updates poetry.lock file
  • /test-pr - Runs tests with the updated PyAirbyte

Community Support

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

📝 Edit this welcome message.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

📝 Walkthrough

Walkthrough

Two integration test files are modified to handle CI infrastructure edge cases by wrapping deployment-related test calls with error handling that skips tests when encountering stale secret reference errors, while preserving existing behavior for successful executions and other exceptions.

Changes

Cohort / File(s) Summary
Test Infrastructure Error Handling
tests/integration_tests/cloud/test_cloud_api_util.py, tests/integration_tests/cloud/test_cloud_workspaces.py
Added SDKError import and STALE_SECRET_REFERENCE_ERROR constant with docstring. Wrapped list_destinations and deployment calls with try/except blocks to detect 500 errors containing "Secret reference"—skipping tests via pytest.skip when detected; otherwise re-raising or preserving original behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Straightforward, repetitive pattern applied consistently across two test files
  • Changes are isolated to error handling in test infrastructure with no impact on production code
  • Clear intent: skip tests on known CI infrastructure issues while preserving all other execution paths

Potential review focus:

  • Verify the error detection logic (checking for "Secret reference" substring) accurately identifies the stale secret edge case without false positives
  • Confirm both files use identical or appropriately matched constants and skip messages for consistency

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: handling stale secret reference errors in cloud integration tests, which aligns with the modifications across both test files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1764662151-fix-cloud-test-secret-reference

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 and usage tips.

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: 1

🧹 Nitpick comments (1)
tests/integration_tests/cloud/test_cloud_api_util.py (1)

21-21: Consider extracting the constant to a shared module to avoid duplication?

The STALE_SECRET_REFERENCE_ERROR constant is defined identically in both tests/integration_tests/cloud/test_cloud_api_util.py and tests/integration_tests/cloud/test_cloud_workspaces.py. To follow DRY principles, you could extract it to a shared test utilities module, wdyt?

For example, you could create a shared module like tests/integration_tests/cloud/test_helpers.py:

# tests/integration_tests/cloud/test_helpers.py
from airbyte_api.errors import SDKError

STALE_SECRET_REFERENCE_ERROR = "Secret reference"
"""Substring to detect stale secret reference errors in the CI workspace.

When the shared CI workspace contains destinations with deleted/stale secret references,
the Airbyte Cloud API returns a 500 error. This is an infrastructure issue, not a code bug.
"""

Then import it in both test files:

from tests.integration_tests.cloud.test_helpers import STALE_SECRET_REFERENCE_ERROR

Also applies to: 31-36

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b9f2fa and f777f8c.

📒 Files selected for processing (2)
  • tests/integration_tests/cloud/test_cloud_api_util.py (3 hunks)
  • tests/integration_tests/cloud/test_cloud_workspaces.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: aaronsteers
Repo: airbytehq/PyAirbyte PR: 347
File: tests/integration_tests/fixtures/registry.json:47-47
Timestamp: 2024-08-31T00:58:32.484Z
Learning: When reviewing changes in test fixtures, especially renaming, consider that they might be due to fixing copy-paste errors and may not impact core codepaths.
Learnt from: aaronsteers
Repo: airbytehq/PyAirbyte PR: 347
File: tests/integration_tests/fixtures/registry.json:47-47
Timestamp: 2024-10-08T15:34:31.026Z
Learning: When reviewing changes in test fixtures, especially renaming, consider that they might be due to fixing copy-paste errors and may not impact core codepaths.
🧬 Code graph analysis (1)
tests/integration_tests/cloud/test_cloud_workspaces.py (1)
airbyte/cloud/workspaces.py (1)
  • deploy_destination (195-248)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Pytest (All, Python 3.11, Windows)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Windows)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (No Creds)
🔇 Additional comments (2)
tests/integration_tests/cloud/test_cloud_workspaces.py (1)

9-9: LGTM on the new imports!

The pytest and SDKError imports are correctly added to support the error handling logic.

Also applies to: 15-15

tests/integration_tests/cloud/test_cloud_api_util.py (1)

96-109: The error handling is correctly applied only to list_destinations.

The stale secret reference error is specific to destinations in the CI workspace infrastructure. The docstring in test_cloud_workspaces.py confirms this: "When the shared CI workspace contains destinations with deleted/stale secret references, the Airbyte Cloud API returns a 500 error. This is an infrastructure issue, not a code bug." Since list_destinations queries all destinations in the workspace, it exposes stale references, whereas list_sources, create_destination, and other operations don't encounter this particular infrastructure issue. No additional error handling is needed elsewhere.

Likely an incorrect or invalid review comment.

Comment on lines +31 to +43
try:
cloud_destination = cloud_workspace.deploy_destination(
name="test-destination-deleteme",
destination=deployable_dummy_destination,
random_name_suffix=True,
)
except SDKError as e:
if e.status_code == 500 and STALE_SECRET_REFERENCE_ERROR in str(e):
pytest.skip(
"CI workspace contains destinations with stale secret references. "
"This is an infrastructure issue, not a code bug."
)
raise
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Find the codebase structure and locate where these methods are defined
git ls-files | head -20

Repository: airbytehq/PyAirbyte

Length of output: 755


🏁 Script executed:

# Search for deploy_source and deploy_destination method definitions
rg "def deploy_source" -A 30

Repository: airbytehq/PyAirbyte

Length of output: 5698


🏁 Script executed:

# Search for deploy_destination method definitions
rg "def deploy_destination" -A 30

Repository: airbytehq/PyAirbyte

Length of output: 3934


🏁 Script executed:

# Look for STALE_SECRET_REFERENCE_ERROR definition and usage
rg "STALE_SECRET_REFERENCE_ERROR" -B 2 -A 2

Repository: airbytehq/PyAirbyte

Length of output: 1847


🏁 Script executed:

# Read the full test file to see all deployment test methods
cat -n tests/integration_tests/cloud/test_cloud_workspaces.py

Repository: airbytehq/PyAirbyte

Length of output: 4557


🏁 Script executed:

# Check if deploy_source is used elsewhere with similar error handling
rg "deploy_source" tests/integration_tests/cloud/test_cloud_workspaces.py -B 3 -A 10

Repository: airbytehq/PyAirbyte

Length of output: 1695


Add error handling to deploy_destination in test_deploy_connection

The deploy_destination call at line 95 can fail with the same stale secret reference error as test_deploy_destination, but lacks error handling. Apply the same try/except pattern from lines 31-43 to handle this infrastructure issue consistently.

(Note: deploy_source does not need this handling—the error is specific to destinations with stale secret references.)

🤖 Prompt for AI Agents
In tests/integration_tests/cloud/test_cloud_workspaces.py around lines 31-43 and
near line 95, add the same try/except handling used for deploy_destination at
lines 31-43 to the deploy_destination call in test_deploy_connection (around
line 95): wrap the deploy_destination invocation in a try block, catch SDKError
as e, check if e.status_code == 500 and STALE_SECRET_REFERENCE_ERROR is in
str(e), call pytest.skip with the same message about CI workspace stale secret
references, and re-raise the exception for other errors so the test behaves
consistently with test_deploy_destination.

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

PyTest Results (Fast Tests Only, No Creds)

320 tests  ±0   320 ✅ ±0   5m 49s ⏱️ +3s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit f777f8c. ± Comparison against base commit 5b9f2fa.

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

PyTest Results (Full)

388 tests  ±0   372 ✅ ±0   27m 33s ⏱️ +47s
  1 suites ±0    16 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit f777f8c. ± Comparison against base commit 5b9f2fa.

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.

2 participants