Skip to content

Commit

Permalink
fix(queries): do not fail on response with 200 code and null body (#1304
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ValeraS authored Sep 16, 2024
1 parent 6d65839 commit d115989
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
const {schema, ...rest} = params;

// FIXME: base64 is passed both to params and body to work on versions before and after 24-3
return this.post<QueryAPIResponse<Action, Schema> | ErrorResponse>(
return this.post<QueryAPIResponse<Action, Schema> | ErrorResponse | null>(
this.getPath('/viewer/json/query'),
{...rest, base64},
{schema, base64},
Expand Down
2 changes: 1 addition & 1 deletion src/store/reducers/cluster/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function getGroupStats(data?: KeyValueRow[] | TStorageStats[]) {
}

export const parseGroupsStatsQueryResponse = (
data: ExecuteQueryResponse<'modern'>,
data: ExecuteQueryResponse<'modern'> | null,
): ClusterGroupsStats => {
const parsedData = parseQueryAPIExecuteResponse(data).result;
return getGroupStats(parsedData);
Expand Down
2 changes: 1 addition & 1 deletion src/store/reducers/executeQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export const executeQueryApi = api.injectEndpoints({
}

const data = parseQueryAPIExecuteResponse(response);
data.traceId = response._meta?.traceId;
data.traceId = response?._meta?.traceId;

const queryStats: QueryStats = {};
if (data.stats) {
Expand Down
2 changes: 1 addition & 1 deletion src/store/reducers/explainQuery/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const explainVersions = {
const supportedExplainQueryVersions = Object.values(explainVersions);

export const prepareExplainResponse = (
response: ExplainScriptResponse | ExplainQueryResponse,
response: ExplainScriptResponse | ExplainQueryResponse | null,
): PreparedExplainResponse => {
const {plan: rawPlan, ast} = parseQueryAPIExplainResponse(response);

Expand Down
2 changes: 1 addition & 1 deletion src/store/reducers/viewSchema/viewSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const viewSchemaApi = api.injectEndpoints({
return {error: response};
}

return {data: response.columns || []};
return {data: response?.columns || []};
} catch (error) {
return {error: error};
}
Expand Down

0 comments on commit d115989

Please sign in to comment.