Skip to content

Commit c788c06

Browse files
committed
fix(repos): Fix vsts sync error
The links field isn't always present. Use `webUrl` instead, and fall back to an empty url as needed Fixes SENTRY-5NAH
1 parent d4c66aa commit c788c06

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

fixtures/vsts.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,7 @@ def _stub_vsts(self):
137137
"id": self.repo_id,
138138
"name": self.repo_name,
139139
"project": {"name": self.project_a["name"]},
140-
"_links": {
141-
"web": {
142-
"href": f"https://{self.vsts_account_name.lower()}.visualstudio.com/_git/{self.repo_name}"
143-
}
144-
},
140+
"webUrl": f"https://{self.vsts_account_name.lower()}.visualstudio.com/_git/{self.repo_name}",
145141
}
146142
]
147143
},

src/sentry/integrations/vsts/integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def get_repositories(
329329
"repo_name": repo["name"],
330330
"identifier": str(repo["id"]),
331331
"external_id": self.get_repo_external_id(repo),
332-
"url": repo["_links"]["web"]["href"],
332+
"url": repo.get("webUrl"),
333333
"instance": self.instance,
334334
"project": repo["project"]["name"],
335335
}

tests/sentry/integrations/source_code_management/test_sync_repos.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,17 +441,13 @@ def test_creates_new_repos_for_vsts(self, mock_get_client: MagicMock) -> None:
441441
"id": "repo-uuid-1",
442442
"name": "cool-service",
443443
"project": {"name": "ProjectA"},
444-
"_links": {
445-
"web": {"href": "https://myvstsaccount.visualstudio.com/_git/cool-service"}
446-
},
444+
"webUrl": "https://myvstsaccount.visualstudio.com/_git/cool-service",
447445
},
448446
{
449447
"id": "repo-uuid-2",
450448
"name": "other-service",
451449
"project": {"name": "ProjectA"},
452-
"_links": {
453-
"web": {"href": "https://myvstsaccount.visualstudio.com/_git/other-service"}
454-
},
450+
"webUrl": "https://myvstsaccount.visualstudio.com/_git/other-service",
455451
},
456452
]
457453
}

0 commit comments

Comments
 (0)