Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions static/app/components/events/autofix/v3/autofixEvidence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import type {LocationDescriptor} from 'history';

import {LinkButton} from '@sentry/scraps/button';

import {RepoProviderIcon} from 'sentry/components/repositories/repoProviderIcon';
import {IconCompass} from 'sentry/icons/iconCompass';
import {IconFile} from 'sentry/icons/iconFile';
import {IconGithub} from 'sentry/icons/iconGithub';
import {IconIssues} from 'sentry/icons/iconIssues';
import {IconPlay} from 'sentry/icons/iconPlay';
import {IconProfiling} from 'sentry/icons/iconProfiling';
Expand Down Expand Up @@ -312,13 +312,21 @@ function getCodeSearchEvidenceProps({
function getGitSearchEvidenceProps({
toolLink,
}: GetEvidencePropsPayload): EvidenceButtonProps | null {
const {repo_name, commit_url, sha, commits_url, start_date, end_date, file_path} =
toolLink?.params ?? {};
const {
repo_name,
commit_url,
sha,
commits_url,
start_date,
end_date,
file_path,
provider,
} = toolLink?.params ?? {};

if (typeof commit_url === 'string' && typeof sha === 'string') {
return {
href: commit_url,
icon: <IconGithub />, // TODO: support other SCMs
icon: <RepoProviderIcon provider={provider ?? 'integrations:github'} />,

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 nullish coalescing operator for the provider parameter doesn't handle empty strings, causing a generic icon to be displayed instead of the intended default GitHub icon.
Severity: LOW

Suggested Fix

Replace the nullish coalescing operator with a more robust check to ensure provider is a non-empty string before use. For example: (provider && typeof provider === 'string') ? provider : 'integrations:github'. This will correctly handle null, undefined, and empty string cases by falling back to the default.

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: static/app/components/events/autofix/v3/autofixEvidence.tsx#L329

Potential issue: The code uses `provider ?? 'integrations:github'` to set a default
value for the `provider` parameter. The nullish coalescing operator (`??`) only provides
a fallback for `null` or `undefined` values, not for an empty string (`""`). If the
backend sends an empty string for `provider`, it will be passed to the
`RepoProviderIcon` component. This component will not find `""` as a valid provider,
will log an error, and will render a generic `<IconOpen />` icon instead of the intended
default GitHub icon, leading to a degraded user experience.

Also affects:

  • static/app/components/events/autofix/v3/autofixEvidence.tsx:345~345

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it should never be an empty string

label: t('Commit: %s', truncateText(getShortCommitHash(sha))),
tooltip: sha,
};
Expand All @@ -334,7 +342,7 @@ function getGitSearchEvidenceProps({
typeof file_path === 'string' ? extractFileName(file_path) : undefined;
return {
href: commits_url,
icon: <IconGithub />, // TODO: support other SCMs
icon: <RepoProviderIcon provider={provider ?? 'integrations:github'} />,
label: t('Commits: %s', fileName ? truncateText(fileName) : repo_name),
tooltip: (
<Fragment>
Comment thread
sentry[bot] marked this conversation as resolved.
Expand Down
Loading