Skip to content

Commit

Permalink
Fix: Return correct error response status (#2053)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaryannGitonga authored Aug 29, 2022
1 parent 7987e01 commit f443f60
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/app/services/actions/query-action-creator-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { IStatus } from '../../../types/status';
import { ClientError } from '../../utils/ClientError';
import { encodeHashCharacters } from '../../utils/query-url-sanitization';
import { translateMessage } from '../../utils/translate-messages';
import { isJsonString } from '../../views/sidebar/sample-queries/sample-query-utils';
import { authProvider, GraphClient } from '../graph-client';
import { DEFAULT_USER_SCOPES } from '../graph-constants';
import { QUERY_GRAPH_SUCCESS } from '../redux-constants';
Expand All @@ -35,7 +36,7 @@ export async function anonymousRequest(
getState: Function
) {
const { proxyUrl, queryRunnerStatus } = getState();
const { graphUrl, options } = createAnonymousRequest(query, proxyUrl, queryRunnerStatus);
const { graphUrl, options } = createAnonymousRequest(query, proxyUrl, queryRunnerStatus);
dispatch(queryRunningStatus(true));
return fetch(graphUrl, options)
.catch(() => {
Expand Down Expand Up @@ -229,8 +230,7 @@ export function parseResponse(
const contentType = getContentType(response.headers);
switch (contentType) {
case ContentType.Json:
return response.json();

return isJsonString(response) ? response.json() : response;
case ContentType.XML:
case ContentType.HTML:
case ContentType.TextPlain:
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/actions/query-action-creators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function runQuery(query: IQuery): Function {
messageType: MessageBarType.error,
ok: false,
duration,
status: 400,
status: response.status || 400,
statusText: ''
};

Expand Down

0 comments on commit f443f60

Please sign in to comment.