From b060761f4b49ce151c16f3b35abee856b77c744c Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 21:41:19 +0000 Subject: [PATCH] fix(mcp): explain 'no sync jobs yet' when sync logs have no history get_cloud_sync_logs raised a generic 'resource does not exist' error when no job_id was given and the connection had never synced. It now tells the caller the connection has no sync jobs and points them at run_cloud_sync. Co-Authored-By: AJ Steers --- airbyte/mcp/cloud.py | 7 ++++++ tests/unit_tests/test_mcp_cloud.py | 37 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/airbyte/mcp/cloud.py b/airbyte/mcp/cloud.py index 05124c5f2..c6295572c 100644 --- a/airbyte/mcp/cloud.py +++ b/airbyte/mcp/cloud.py @@ -2271,6 +2271,13 @@ def get_cloud_sync_logs( sync_result: SyncResult | None = connection.get_sync_result(job_id=job_id) if not sync_result: + if job_id is None: + raise AirbyteMissingResourceError( + resource_type="sync job", + resource_name_or_id=connection_id, + message=f"Connection '{connection_id}' has no sync jobs yet.", + guidance="Run a sync first with `run_cloud_sync`, then request its logs.", + ) raise AirbyteMissingResourceError( resource_type="sync job", resource_name_or_id=connection_id, diff --git a/tests/unit_tests/test_mcp_cloud.py b/tests/unit_tests/test_mcp_cloud.py index 45536142f..368e6f491 100644 --- a/tests/unit_tests/test_mcp_cloud.py +++ b/tests/unit_tests/test_mcp_cloud.py @@ -1068,6 +1068,43 @@ def test_get_cloud_sync_status_surfaces_library_errors( get_attempts.assert_called_once_with() +def test_get_cloud_sync_logs_without_jobs_explains_no_syncs_yet( + monkeypatch: pytest.MonkeyPatch, +) -> None: + """A connection with no sync history gets an actionable message, not 'not found'.""" + connection = SimpleNamespace( + get_sync_result=MagicMock(return_value=None), + ) + _patch_sync_status_workspace(monkeypatch, connection) + + with pytest.raises(AirbyteMissingResourceError) as exc_info: + cloud_mcp.get_cloud_sync_logs( + cast(Context, object()), + connection_id="connection-1", + job_id=None, + workspace_id=None, + max_lines=100, + from_tail=None, + line_offset=None, + ) + + assert "Connection 'connection-1' has no sync jobs yet." in str(exc_info.value) + assert "run_cloud_sync" in (exc_info.value.guidance or "") + + with pytest.raises(AirbyteMissingResourceError) as explicit_exc_info: + cloud_mcp.get_cloud_sync_logs( + cast(Context, object()), + connection_id="connection-1", + job_id=42, + workspace_id=None, + max_lines=100, + from_tail=None, + line_offset=None, + ) + + assert "does not exist" in str(explicit_exc_info.value) + + def test_set_cloud_connection_selected_streams_surfaces_library_error( monkeypatch: pytest.MonkeyPatch, ) -> None: