Skip to content

Conversation

@Mohit-Lakra
Copy link

@Mohit-Lakra Mohit-Lakra commented Dec 14, 2025

Brief summary of changes

  • Guard the Define Filters candidate-count fetch when no fields are selected so removing PSCID no longer blanks the
    tab.
  • Wrap the auto-count fetch in an abortable helper with logging so errors don’t take down the UI.

Testing instructions

  1. With permissions limited to “Data Query Tool (Beta): Cross-Modality Data” and “Data Dictionary: Parameter Type
    Descriptions”, open the Data Query Tool.
  2. Go to “Define Fields”, remove the default PSCID entry, and confirm the page stays responsive and the “Define
    Filters” tab opens normally.
  3. Run npm run lint:js (passes; existing repo warnings only).

Link(s) to related issue(s)

Before Fix
After

After Fix
Screenshot 2025-12-14 at 9 14 43 PM

Copilot AI review requested due to automatic review settings December 14, 2025 17:01
@github-actions github-actions bot added the Module: dataquery PR or issue related to (new) dataquery module label Dec 14, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a UI crash in the Data Query Tool that occurred when users removed the PSCID field from the "Define Fields" tab, causing the "Define Filters" tab to become unresponsive. The fix adds proper guards and error handling for the candidate count fetch operation.

Key Changes:

  • Added a guard condition to prevent fetching candidate counts when no fields are selected
  • Refactored the count-fetching logic from promise chains to async/await with proper abort handling
  • Implemented cleanup mechanism using AbortController to cancel in-flight requests when the component unmounts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 103 to +117
throw new Error('Error creating query.');
}
return resp.json();
}
).then(
(data) => {
fetch(
'/dataquery/queries/'
+ data.QueryID + '/count',

const data = await createResp.json();
const countResp = await fetch(
`/dataquery/queries/${data.QueryID}/count`,
{
method: 'GET',
credentials: 'same-origin',
}
).then((resp) => {
if (!resp.ok) {
throw new Error('Could not get count.');
}
return resp.json();
}).then((result) => {
signal: controller.signal,
},
);

if (!countResp.ok) {
throw new Error('Could not get count.');
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

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

The error messages "Error creating query." and "Could not get count." are generic and don't provide helpful context for debugging. Consider including the HTTP status code or response details to help identify the root cause when these errors occur. For example: throw new Error(\Error creating query: ${createResp.status} ${createResp.statusText}`);`

Copilot uses AI. Check for mistakes.
@Mohit-Lakra
Copy link
Author

@driusan, could you please assign someone to review this PR? I’d really appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module: dataquery PR or issue related to (new) dataquery module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dataquery] GUI behaviour with partial permissions

1 participant