Skip to content

fix(sync_repos): Handle string JSON in VSTS and error dicts in GitLab#114656

Open
wedamija wants to merge 1 commit intomasterfrom
danf/sync-repos-bugfixes
Open

fix(sync_repos): Handle string JSON in VSTS and error dicts in GitLab#114656
wedamija wants to merge 1 commit intomasterfrom
danf/sync-repos-bugfixes

Conversation

@wedamija
Copy link
Copy Markdown
Member

@wedamija wedamija commented May 1, 2026

Guard against non-dict exc.json in message_from_error and validate that GitLab search_projects returns project dicts, not error keys.

Fixes SENTRY-5NAY
Fixes SENTRY-5NBH

Guard against non-dict exc.json in message_from_error and validate
that GitLab search_projects returns project dicts, not error keys.

Fixes SENTRY-5NAY
Fixes SENTRY-5NBH
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@wedamija wedamija requested a review from a team May 1, 2026 23:48
@wedamija wedamija requested review from a team as code owners May 1, 2026 23:48
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 1, 2026
Comment on lines +530 to 533
if exc.json and isinstance(exc.json, dict):
msg = self.error_message_from_json(exc.json) or "unknown error"
else:
msg = "unknown error"
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: The raise_error method may cause an AttributeError by passing a non-dictionary exc.json to error_fields_from_json, which expects a dictionary.
Severity: MEDIUM

Suggested Fix

In the raise_error method, add a check to ensure exc.json is a dictionary before passing it to self.error_fields_from_json. For example: if exc.json and isinstance(exc.json, dict):.

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/base.py#L530-L533

Potential issue: The `raise_error` method calls `self.error_fields_from_json(exc.json)`
if `exc.json` is truthy, but it does not validate that `exc.json` is a dictionary.
Subclasses like `JiraIntegration` and `JiraServerIntegration` implement
`error_fields_from_json` by calling the `.get()` method on the input, assuming it is a
dictionary. If an API returns a non-dictionary JSON response, such as a string,
`exc.json` will be a truthy string. This will cause an `AttributeError` when `.get()` is
called, crashing the integration's error handling logic.

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