Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,37 @@ describe('useCopyIssueDetails', () => {
expect(result).toContain('## Plan');
});

it('includes the message when it differs from the title', () => {
const result = issueAndEventToMarkdown({
group: GroupFixture({title: 'TypeError'}),
event: EventFixture({...event, message: 'Connection to database timed out'}),
organization,
});

expect(result).toContain('## Message');
expect(result).toContain('Connection to database timed out');
});

it('omits the message when it is already part of the title', () => {
const result = issueAndEventToMarkdown({
group: GroupFixture({title: 'TypeError: connection failed'}),
event: EventFixture({...event, message: 'connection failed'}),
organization,
});

expect(result).not.toContain('## Message');
});

it('omits the message when it is empty', () => {
const result = issueAndEventToMarkdown({
group: GroupFixture({title: 'TypeError'}),
event: EventFixture({...event, message: ' '}),
organization,
});

expect(result).not.toContain('## Message');
});

it('includes tags when present in event', () => {
const eventWithTags = {
...event,
Expand Down
7 changes: 7 additions & 0 deletions static/app/views/issueDetails/hooks/useCopyIssueDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ export const issueAndEventToMarkdown = ({
markdownText += `**Date:** ${new Date(event.dateCreated).toLocaleString()}\n`;
}

// Mirror Seer: include the event message only when it adds something beyond
// the title, since for most errors the title already is the message.
const message = event?.message?.trim();
if (message && !group.title.includes(message)) {

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 case-sensitive check group.title.includes(message) may fail to detect when the message is already in the title if their casing differs, leading to redundant output.
Severity: LOW

Suggested Fix

Perform a case-insensitive comparison to correctly detect if the message is already in the title. Convert both group.title and message to the same case before the check, for example: group.title.toLowerCase().includes(message.toLowerCase()).

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/views/issueDetails/hooks/useCopyIssueDetails.tsx#L278

Potential issue: The code uses a case-sensitive `String.prototype.includes()` to check
if an event's `message` is already contained within the `group.title` before adding it
to a generated markdown string. This is intended to prevent duplicating information.
However, if the `message` and its representation in the `title` differ only by case
(e.g., `title` is 'Error: Something failed' and `message` is 'something failed'), the
check will incorrectly return false. This results in the message being redundantly added
to the markdown output.

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

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.

doing it this way to match Seer

markdownText += `\n## Message\n\n${message}\n`;
}

if (autofixData) {
const sections = getOrderedAutofixSections(autofixData);
const rootCauseSection = sections.find(isRootCauseSection);
Expand Down
Loading