Skip to content

Conversation

@cvxluo
Copy link
Contributor

@cvxluo cvxluo commented Nov 25, 2025

Brings the "paste json" button back

Screenshot 2025-11-25 at 3 26 04 PM

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 25, 2025
@cvxluo cvxluo force-pushed the cvxluo/pasting-json-top-issues branch from 27e4c0e to 05368ff Compare November 25, 2025 23:24
@cvxluo cvxluo force-pushed the cvxluo/pasting-json-top-issues branch from 05368ff to d6a37c3 Compare November 25, 2025 23:25
@cvxluo cvxluo changed the title wip(issues): pasting json top issues feat(issues): allow pasting json top issues Nov 25, 2025
@cvxluo cvxluo marked this pull request as ready for review November 25, 2025 23:26
@cvxluo cvxluo requested a review from a team as a code owner November 25, 2025 23:26
@cvxluo cvxluo requested a review from scttcper November 25, 2025 23:26
}, []);

const clusterData = customClusterData ?? topIssuesResponse?.data ?? [];
const isUsingCustomData = customClusterData !== null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Team filter uses API data instead of custom data

The teamsInData memo extracts teams from topIssuesResponse?.data instead of clusterData, which includes custom JSON data. When users paste custom JSON, team filtering won't work because the team extraction logic ignores the custom data and only looks at API data. The dependency array also needs updating to track clusterData or customClusterData.

Additional Locations (1)

Fix in Cursor Fix in Web

Comment on lines 385 to 386
// Extract all unique teams from the cluster data
const teamsInData = useMemo(() => {
Copy link

Choose a reason for hiding this comment

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

Bug: Team filter is not populated when customClusterData is used because teamsInData only extracts from topIssuesResponse?.data.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The teamsInData useMemo hook only extracts teams from topIssuesResponse?.data and depends solely on it. However, the displayed clusterData uses customClusterData ?? topIssuesResponse?.data. When customClusterData is present, the API query for topIssuesResponse?.data is disabled, leading to an empty teamsInData. This causes the team filter section to be hidden, preventing users from filtering by team when using custom JSON data.

💡 Suggested Fix

Modify the teamsInData useMemo to extract teams from clusterData instead of topIssuesResponse?.data, and update its dependency array to include clusterData.

🤖 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/issueList/pages/dynamicGrouping.tsx#L385-L386

Potential issue: The `teamsInData` `useMemo` hook only extracts teams from
`topIssuesResponse?.data` and depends solely on it. However, the displayed `clusterData`
uses `customClusterData ?? topIssuesResponse?.data`. When `customClusterData` is
present, the API query for `topIssuesResponse?.data` is disabled, leading to an empty
`teamsInData`. This causes the team filter section to be hidden, preventing users from
filtering by team when using custom JSON data.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3632176

Comment on lines +364 to +374
if (!Array.isArray(clusters)) {
setJsonError(t('JSON must be an array or have a "data" property with an array'));
return;
}
setCustomClusterData(clusters as ClusterSummary[]);
setJsonError(null);
setShowJsonInput(false);
} catch (e) {
setJsonError(t('Invalid JSON: %s', e instanceof Error ? e.message : String(e)));
}
}, [jsonInputValue]);
Copy link

Choose a reason for hiding this comment

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

Bug: Insufficient JSON validation in handleParseJson can cause runtime TypeError when required properties are missing from custom data.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The handleParseJson function performs insufficient validation on user-provided JSON. It only checks for valid JSON syntax and array structure, but does not verify if required properties like group_ids or cluster_id exist within each object. This can lead to runtime TypeError exceptions (e.g., Cannot read property 'length' of undefined or Cannot read property 'join' of undefined) when components like ClusterCard attempt to access these missing properties, causing the UI to crash.

💡 Suggested Fix

Implement robust schema validation for the parsed JSON objects within handleParseJson to ensure all ClusterSummary required properties (e.g., group_ids, cluster_id, title) are present before setting customClusterData.

🤖 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/issueList/pages/dynamicGrouping.tsx#L359-L374

Potential issue: The `handleParseJson` function performs insufficient validation on
user-provided JSON. It only checks for valid JSON syntax and array structure, but does
not verify if required properties like `group_ids` or `cluster_id` exist within each
object. This can lead to runtime `TypeError` exceptions (e.g., `Cannot read property
'length' of undefined` or `Cannot read property 'join' of undefined`) when components
like `ClusterCard` attempt to access these missing properties, causing the UI to crash.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3632176

@cvxluo cvxluo merged commit f7ac1bc into master Nov 25, 2025
50 checks passed
@cvxluo cvxluo deleted the cvxluo/pasting-json-top-issues branch November 25, 2025 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants