-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(issues): allow pasting json top issues #104022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
27e4c0e to
05368ff
Compare
05368ff to
d6a37c3
Compare
| }, []); | ||
|
|
||
| const clusterData = customClusterData ?? topIssuesResponse?.data ?? []; | ||
| const isUsingCustomData = customClusterData !== null; |
There was a problem hiding this comment.
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)
| // Extract all unique teams from the cluster data | ||
| const teamsInData = useMemo(() => { |
There was a problem hiding this comment.
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
| 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]); |
There was a problem hiding this comment.
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
Brings the "paste json" button back