Skip to content
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion src/sentry/issues/auto_source_code_config/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
SUPPORTED_INTEGRATIONS = [IntegrationProviderSlug.GITHUB.value]
STACK_ROOT_MAX_LEVEL = 4

# Any new languages should also require updating the stacktraceLink.tsx
Copy link
Member Author

Choose a reason for hiding this comment

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

Both frontend & backend changes in this PR but it's fine; the backend change is just this comment removal

# The extensions do not need to be exhaustive but only include the ones that show up in stacktraces
PLATFORMS_CONFIG: dict[str, Mapping[str, Any]] = {
# C#, F#, VB, PowerShell, C# Script, F# Script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('StacktraceLink', () => {
});
});

it('should hide stacktrace link error state on unsupported platforms', async () => {
it('should show setup button for native platforms', async () => {
MockApiClient.addMockResponse({
url: `/projects/${org.slug}/${project.slug}/stacktrace-link/`,
body: {
Expand All @@ -112,17 +112,15 @@ describe('StacktraceLink', () => {
integrations: [integration],
},
});
const {container} = render(
render(
<StacktraceLink
frame={frame}
event={{...event, platform: 'unreal'}}
event={{...event, platform: 'cocoa'}}
line=""
disableSetup={false}
/>
);
await waitFor(() => {
expect(container).toBeEmptyDOMElement();
});
expect(await screen.findByText('Set up Code Mapping')).toBeInTheDocument();
});

it('renders the codecov link', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type {Event, Frame} from 'sentry/types/event';
import type {StacktraceLinkResult} from 'sentry/types/integrations';
import {CodecovStatusCode} from 'sentry/types/integrations';
import type {Organization} from 'sentry/types/organization';
import type {PlatformKey} from 'sentry/types/project';
import {trackAnalytics} from 'sentry/utils/analytics';
import {getAnalyticsDataForEvent} from 'sentry/utils/events';
import {getIntegrationIcon, getIntegrationSourceUrl} from 'sentry/utils/integrationUtil';
Expand All @@ -29,22 +28,6 @@ import useProjects from 'sentry/utils/useProjects';
import StacktraceLinkModal from './stacktraceLinkModal';
import useStacktraceLink from './useStacktraceLink';

// Keep this list in sync with PLATFORMS_CONFIG in auto_source_code_config/constants.py
const supportedStacktracePlatforms: PlatformKey[] = [
'clojure',
'csharp',
'elixir', // Elixir is not listed on the main list
'go',
'groovy',
'java',
'javascript',
'node',
'php',
'python',
'ruby',
'scala',
];

const scmProviders = ['github', 'gitlab', 'bitbucket'];

interface StacktraceLinkProps {
Expand Down Expand Up @@ -231,11 +214,8 @@ export function StacktraceLink({frame, event, line, disableSetup}: StacktraceLin
// Check if the line starts and ends with {snip}
const isMinifiedJsError =
event.platform === 'javascript' && /(\{snip\}).*\1/.test(line ?? '');
const isUnsupportedPlatform = !supportedStacktracePlatforms.includes(
event.platform as PlatformKey
);

const hideErrors = isMinifiedJsError || isUnsupportedPlatform || disableSetup;
const hideErrors = isMinifiedJsError || disableSetup;
Copy link
Contributor

Choose a reason for hiding this comment

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

Unhandled KeyError crashes save for new platforms

High Severity

Removing the supportedStacktracePlatforms filter now shows the "Set up Code Mapping" modal for platforms not in PLATFORMS_CONFIG (e.g., cocoa, swift, native). When the user saves, create_frame_info calls PlatformConfig(platform), which does dict(PLATFORMS_CONFIG[platform]), raising a KeyError. The repo-path-parsing POST endpoint only catches UnsupportedFrameInfo, not KeyError, so this results in an unhandled 500 error — making the new feature non-functional for the very platforms it aims to support.

Fix in Cursor Fix in Web

Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: The /repo-path-parsing/ endpoint will raise an unhandled KeyError when processing a request for an unsupported platform, leading to a 500 error.
Severity: MEDIUM

Suggested Fix

In src/sentry/api/endpoints/project_repo_path_parsing.py, add a try...except KeyError block to catch the error raised for unsupported platforms. This will allow the endpoint to return a graceful 400 Bad Request response, similar to how the corresponding GET endpoint already handles this case.

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/interfaces/frame/stacktraceLink.tsx#L218

Potential issue: The frontend change allows the "Set Up Code Mapping" button for all
platforms, but the backend does not support all of them. When a user on an unsupported
platform (e.g., `cocoa`) proceeds to the final step of setting up code mapping, a POST
request is made to the `/projects/{org}/{project}/repo-path-parsing/` endpoint. This
endpoint attempts to look up the platform in `PLATFORMS_CONFIG`, which raises a
`KeyError` for unsupported platforms. Because the endpoint does not handle `KeyError`,
the exception is unhandled, resulting in a 500 Internal Server Error.

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

// for .NET projects, if there is no match found but there is a GitHub source link, use that
if (
frame.sourceLink &&
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/events/interfaces/nativeFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ function NativeFrame({
: tn('Show %s more frame', 'Show %s more frames', hiddenFrameCount)}
</ShowHideButton>
) : null}
<Flex>
<Flex align="center" gap="sm">
Copy link
Member Author

Choose a reason for hiding this comment

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

These changes are so that:

  1. The "In App" badge remains vertically centered in the stack frame row
  2. There is some horizontal spacing between the "Set Up Code Mapping" button and the "In App" badge in each stack frame row

{showStacktraceLink && (
<ErrorBoundary>
<StacktraceLink
Expand Down
Loading