Skip to content

Commit 6000ceb

Browse files
authored
Merge branch 'main' into wtj/DI-leak-internal-url-dbt-mcp
2 parents 4b1b345 + 45c8b68 commit 6000ceb

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Bug Fix
2+
body: Handle null data in list_job_run_artifacts when a run produced no artifacts
3+
time: 2026-06-03T11:24:34.706505-05:00

src/dbt_mcp/dbt_admin/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ async def list_job_run_artifacts(self, account_id: int, run_id: int) -> list[str
362362
result = await self._make_request(
363363
"GET", f"/api/v2/accounts/{account_id}/runs/{run_id}/artifacts/"
364364
)
365-
data = result.get("data", [])
365+
# The API returns {"data": null} when a run produced no artifacts, so
366+
# coalesce to a list rather than passing the null through to iteration.
367+
data = result.get("data") or []
366368

367369
# we remove the compiled and run artifacts, they are not very relevant and there are thousands of them, filling the context
368370
filtered_data = [

tests/unit/dbt_admin/test_client.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,22 @@ async def test_list_job_run_artifacts(client):
561561
)
562562

563563

564+
async def test_list_job_run_artifacts_null_data(client):
565+
# The dbt Cloud API returns {"data": null} when a run produced no
566+
# artifacts (e.g. it errored before generating any). The null must be
567+
# normalized to an empty list rather than iterated over.
568+
mock_response = MagicMock()
569+
mock_response.json.return_value = {"data": None}
570+
mock_response.raise_for_status.return_value = None
571+
572+
mock_client = create_mock_httpx_client(mock_response)
573+
574+
with patch("httpx.AsyncClient", return_value=mock_client):
575+
result = await client.list_job_run_artifacts(12345, 100)
576+
577+
assert result == []
578+
579+
564580
async def test_get_job_run_artifact_json(client):
565581
mock_response = MagicMock()
566582
mock_response.text = '{"nodes": {"model.test": {}}}'

0 commit comments

Comments
 (0)