insights: aggregations limit errors for mode availability queries
Created by: chwarwick
Previously if the search query couldn't be parsed checking the availability of the aggregation mode would error. This did not align with what happened when attempting to run the aggregation. That would return a NotAvailable response with details that the search query was not valid. This brings the mode availability in alignment. In cases when it's not determined if the mode is supported false
is the default.
It could still be possible for an array of errors to be returned if the query were to ask for the reasonUnavailable
and that were to error for multiple modes. I believe this is ok because those errors would be relevant to the specific mode and it is a nullable field.
resolves https://github.com/sourcegraph/sourcegraph/issues/40971
Test plan
Query
{
searchQueryAggregate(query: "i++ patterntype:regexp",patternType:regexp) {
modeAvailability {
mode
available
reasonUnavailable
}
}
}
Response
{
"data": {
"searchQueryAggregate": {
"modeAvailability": [
{
"__typename": "AggregationModeAvailability",
"mode": "REPO",
"available": false,
"reasonUnavailable": "Grouping is disabled because the search query is not valid."
},
{
"__typename": "AggregationModeAvailability",
"mode": "PATH",
"available": false,
"reasonUnavailable": "Grouping is disabled because the search query is not valid."
},
{
"__typename": "AggregationModeAvailability",
"mode": "AUTHOR",
"available": false,
"reasonUnavailable": "Grouping is disabled because the search query is not valid."
},
{
"__typename": "AggregationModeAvailability",
"mode": "CAPTURE_GROUP",
"available": false,
"reasonUnavailable": "Grouping is disabled because the search query is not valid."
}
],
"__typename": "SearchQueryAggregate"
}
}
}