Skip to content

fix(repos): Fix vsts sync error#113136

Open
wedamija wants to merge 1 commit intomasterfrom
danf/fix-vsts-error
Open

fix(repos): Fix vsts sync error#113136
wedamija wants to merge 1 commit intomasterfrom
danf/fix-vsts-error

Conversation

@wedamija
Copy link
Copy Markdown
Member

The links field isn't always present. Use webUrl instead, and fall back to an empty url as needed

Fixes SENTRY-5NAH

The links field isn't always present. Use `webUrl` instead, and fall back to an empty url as needed

Fixes SENTRY-5NAH
@wedamija wedamija requested a review from a team April 15, 2026 23:21
@wedamija wedamija requested review from a team as code owners April 15, 2026 23:21
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 15, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c788c06. Configure here.

"identifier": str(repo["id"]),
"external_id": self.get_repo_external_id(repo),
"url": repo["_links"]["web"]["href"],
"url": repo.get("webUrl"),
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.

repo.get("webUrl") returns None instead of empty string

High Severity

repo.get("webUrl") returns None when webUrl is absent, but the PR description says to "fall back to an empty url as needed." Downstream, build_repository_config in repository.py passes data["url"] into RpcCreateRepository, which declares url: str (non-optional). A None value here will either cause a Pydantic validation error or be coerced to the string "None". Using repo.get("webUrl", "") would match the stated intent and avoid the type mismatch.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c788c06. Configure here.

"identifier": str(repo["id"]),
"external_id": self.get_repo_external_id(repo),
"url": repo["_links"]["web"]["href"],
"url": repo.get("webUrl"),
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.

Bug: repo.get("webUrl") can return None if the key is missing, but the value is used for a non-optional str field, RpcCreateRepository.url, which will cause a validation error.
Severity: HIGH

Suggested Fix

Change repo.get("webUrl") to repo.get("webUrl", "") to provide an empty string as a default value. This will satisfy the str type requirement for the RpcCreateRepository.url field.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/sentry/integrations/vsts/integration.py#L332

Potential issue: The code at `src/sentry/integrations/vsts/integration.py:332` uses
`repo.get("webUrl")` to retrieve a repository's URL. If the `webUrl` key is not present
in the `repo` dictionary, this expression evaluates to `None`. This `None` value is then
used to populate the `url` field of an `RpcCreateRepository` object. However, this field
is defined as a non-optional `str`. When the automatic repository syncing process
encounters a repository without a `webUrl`, passing `None` to this Pydantic model will
raise a validation error, causing the sync task to crash. This contradicts the PR's
stated intent to fall back to an empty string.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant