Skip to content

test(cloud): deflake httpbin-dependent URL construction tests#1075

Merged
Aaron ("AJ") Steers (aaronsteers) merged 2 commits into
mainfrom
devin/1784013784-deflake-httpbin-cloud-tests
Jul 14, 2026
Merged

test(cloud): deflake httpbin-dependent URL construction tests#1075
Aaron ("AJ") Steers (aaronsteers) merged 2 commits into
mainfrom
devin/1784013784-deflake-httpbin-cloud-tests

Conversation

@aaronsteers

@aaronsteers Aaron ("AJ") Steers (aaronsteers) commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary

test_404_error_includes_request_url_context and test_url_construction_with_path_prefix in tests/integration_tests/cloud/test_cloud_api_util.py pointed the SDK at the live public httpbin.org to simulate API responses. Whenever httpbin was overloaded it returned 502/503 instead of the expected 404/200, failing the "All" pytest matrix jobs intermittently — seen on #1072 (assert 503 == 404, then assert 502 == 404 on a different runner across reruns).

These are the only two tests in the file that don't take live-Cloud fixtures, so they run in the credential-free matrix jobs — exactly where the external dependency caused non-deterministic failures unrelated to the code under test.

Fix: mock the HTTP layer with responses (already a dev dependency) instead of hitting httpbin. This preserves the original intent — verifying the SDK's real URL construction — while removing the external dependency:

  • 404 test: register a mocked 404 for GET .../sources and assert the captured request_url context (host, /sources path, workspaceIds query param) exactly as before.
  • Path-prefix test: register a mocked 200 empty-list response for .../api/public/v1/sources and additionally assert the actual sent URL preserved the /api/public/v1 prefix via responses.calls[0].request.url, which is stronger than the prior result == [] check.
@responses.activate
def test_url_construction_with_path_prefix() -> None:
    responses.add(responses.GET, re.compile(r".../api/public/v1/sources.*"),
                  json={"data": [], "next": None, "previous": None}, status=200)
    result = api_util.list_sources(api_root=".../api/public/v1", ...)
    assert result == []
    assert "/api/public/v1/sources" in responses.calls[0].request.url

Both tests now run offline in ~0.2s. No production code changed.

Requested by AJ Steers after the flaky failure was noticed on #1072.

Link to Devin session: https://app.devin.ai/sessions/5bfc7d5ac9544cf1be05a9b1631cc890
Requested by: Aaron ("AJ") Steers (@aaronsteers)

Summary by CodeRabbit

  • Tests
    • Improved integration test coverage for cloud API error handling, including validating that 404 errors retain the correct request URL host context.
    • Enhanced URL construction tests to ensure path prefixes are included correctly, with assertions on returned results and that only the expected request is sent.
    • Removed reliance on external test endpoints and eliminated debug output from the path-prefix test.

Important

Auto-merge enabled.

This PR is set to merge automatically when all requirements are met.

…l dependency

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

Copy link
Copy Markdown
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, CI, and merge conflict monitoring

@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@devin/1784013784-deflake-httpbin-cloud-tests' pyairbyte --help

# Install PyAirbyte from this branch for development:
pip install 'git+https://github.com/airbytehq/PyAirbyte.git@devin/1784013784-deflake-httpbin-cloud-tests'

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 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The cloud API utility integration tests now use responses with a fixed API host, validate parsed request URL context for 404 errors, and verify that URL path prefixes are preserved in mocked source-list requests.

Changes

Cloud API utility test coverage

Layer / File(s) Summary
Mocked API URL validation
tests/integration_tests/cloud/test_cloud_api_util.py
Module-level URL and regex imports support responses matchers; the 404 test validates api.airbyte.example, while the path-prefix test verifies an empty result, one request, and the /api/public/v1/sources path.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: deflaking cloud URL construction tests that depended on httpbin.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch devin/1784013784-deflake-httpbin-cloud-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 (1)
tests/integration_tests/cloud/test_cloud_api_util.py (1)

410-411: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider using urlparse for a more robust path assertion.

To make this assertion a bit more robust and consistent with the previous test, how about using urlparse to verify the path exactly? This avoids any potential false positives if the string somehow ended up in a query parameter. wdyt?

♻️ Proposed refactor
-    assert "/api/public/v1/sources" in sent_url, (
-        f"Expected path prefix '/api/public/v1' to be preserved, got '{sent_url}'"
-    )
+    parsed = urlparse(sent_url)
+    assert parsed.path == "/api/public/v1/sources", (
+        f"Expected path '/api/public/v1/sources', got '{parsed.path}'"
+    )
🤖 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 `@tests/integration_tests/cloud/test_cloud_api_util.py` around lines 410 - 411,
Update the URL assertion in the relevant cloud API test to parse sent_url with
the existing urlparse utility and compare its path exactly against
/api/public/v1/sources, avoiding substring matching against query parameters.
🤖 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 `@tests/integration_tests/cloud/test_cloud_api_util.py`:
- Around line 410-411: Update the URL assertion in the relevant cloud API test
to parse sent_url with the existing urlparse utility and compare its path
exactly against /api/public/v1/sources, avoiding substring matching against
query parameters.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e7566748-e829-43c7-93c8-2b867735237d

📥 Commits

Reviewing files that changed from the base of the PR and between 5ba44a2 and 8e83163.

📒 Files selected for processing (1)
  • tests/integration_tests/cloud/test_cloud_api_util.py

@devin-ai-integration

Copy link
Copy Markdown
Contributor

☑️ Resolved in 5d64c2e (re: CodeRabbit nitpick on the path assertion). Switched the path-prefix test to exact-match via urlparse instead of substring, matching the 404 test's style and avoiding query-param false positives:

sent_path = urlparse(sent_url).path
assert sent_path == "/api/public/v1/sources", ...

Devin session

@github-code-quality

github-code-quality Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: Python

Python / code-coverage/pytest-fast

The overall coverage in the branch is 67%. The coverage in the branch is 65%.

Show a code coverage summary of the most impacted files.
File d9f652f 5d64c2e +/-
airbyte/_util/api_util.py 36% 37% +1%
airbyte/registry.py 70% 72% +2%
airbyte/mcp/server.py 69% 78% +9%
airbyte/mcp/int...c_history_ui.py 0% 36% +36%
airbyte/mcp/int...hared_models.py 0% 81% +81%
airbyte/cloud/models.py 0% 91% +91%
airbyte/mcp/int..._registry_ui.py 0% 92% +92%
airbyte/mcp/int...nc_status_ui.py 0% 97% +97%
airbyte/mcp/int...ive/__init__.py 0% 100% +100%
airbyte/mcp/int...tive/_prefab.py 0% 100% +100%

Python / code-coverage/pytest-no-creds

The overall coverage in the branch is 67%. The coverage in the branch is 65%.

Show a code coverage summary of the most impacted files.
File d9f652f 5d64c2e +/-
airbyte/_util/api_util.py 36% 37% +1%
airbyte/registry.py 70% 72% +2%
airbyte/mcp/server.py 69% 78% +9%
airbyte/mcp/int...c_history_ui.py 0% 36% +36%
airbyte/mcp/int...hared_models.py 0% 81% +81%
airbyte/cloud/models.py 0% 91% +91%
airbyte/mcp/int..._registry_ui.py 0% 92% +92%
airbyte/mcp/int...nc_status_ui.py 0% 97% +97%
airbyte/mcp/int...ive/__init__.py 0% 100% +100%
airbyte/mcp/int...tive/_prefab.py 0% 100% +100%

Python / code-coverage/pytest

The overall coverage in the branch is 72%. The coverage in the branch is 71%.

Show a code coverage summary of the most impacted files.
File d9f652f 5d64c2e +/-
airbyte/_util/api_util.py 72% 72% 0%
airbyte/registry.py 70% 72% +2%
airbyte/mcp/server.py 69% 78% +9%
airbyte/mcp/int...c_history_ui.py 0% 36% +36%
airbyte/mcp/int...hared_models.py 0% 81% +81%
airbyte/mcp/int..._registry_ui.py 0% 92% +92%
airbyte/cloud/models.py 0% 93% +93%
airbyte/mcp/int...nc_status_ui.py 0% 97% +97%
airbyte/mcp/int...ive/__init__.py 0% 100% +100%
airbyte/mcp/int...tive/_prefab.py 0% 100% +100%

Updated July 14, 2026 07:54 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@aaronsteers Aaron ("AJ") Steers (aaronsteers) marked this pull request as ready for review July 14, 2026 07:38
Copilot AI review requested due to automatic review settings July 14, 2026 07:38

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Copilot AI 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.

Pull request overview

Removes flaky integration tests that depended on the public httpbin.org service by mocking the HTTP layer with responses, while still asserting the SDK’s real URL construction behavior (including query params and path-prefix handling).

Changes:

  • Replaced live httpbin.org calls with responses-mocked 404 and 200 responses for deterministic offline runs.
  • Strengthened the path-prefix test by asserting the actual request path sent (responses.calls[0].request.url), not just the returned value.
  • Cleaned up test output by removing debug print statements and centralizing URL parsing utilities at module scope.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aaronsteers Aaron ("AJ") Steers (aaronsteers) merged commit 6a1ce75 into main Jul 14, 2026
26 checks passed
@aaronsteers Aaron ("AJ") Steers (aaronsteers) deleted the devin/1784013784-deflake-httpbin-cloud-tests branch July 14, 2026 07:54
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