Revert "Frontend: Use safe stringifier in parseBody" (#90522)

Revert "Frontend: Use safe stringifier in parseBody (#90047)"

This reverts commit 434f386982.
This commit is contained in:
Ivan Ortega Alba 2024-07-17 13:00:01 +02:00 committed by GitHub
parent 8f376a302b
commit 3559c5c297
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 22 deletions

View File

@ -246,7 +246,7 @@ export {
} from './utils/csv';
export { parseLabels, findCommonLabels, findUniqueLabels, matchAllLabels, formatLabels } from './utils/labels';
export { roundDecimals, guessDecimals } from './utils/numbers';
export { objRemoveUndefined, isEmptyObject, safeStringifyValue } from './utils/object';
export { objRemoveUndefined, isEmptyObject } from './utils/object';
export { classicColors } from './utils/namedColorsPalette';
export { getSeriesTimeStep, hasMsResolution } from './utils/series';
export { BinaryOperationID, type BinaryOperation, binaryOperators } from './utils/binaryOperators';

View File

@ -10,22 +10,3 @@
export const isEmptyObject = (value: unknown): value is Record<string, never> => {
return typeof value === 'object' && value !== null && Object.keys(value).length === 0;
};
/** Stringifies an object that may contain circular references */
export function safeStringifyValue(value: unknown) {
const getCircularReplacer = () => {
const seen = new WeakSet();
return (_: string, value: object | null) => {
if (typeof value === 'object' && value !== null) {
if (seen.has(value)) {
return;
}
seen.add(value);
}
return value;
};
};
return JSON.stringify(value, getCircularReplacer());
}

View File

@ -1,6 +1,6 @@
import { omitBy } from 'lodash';
import { deprecationWarning, safeStringifyValue } from '@grafana/data';
import { deprecationWarning } from '@grafana/data';
import { BackendSrvRequest } from '@grafana/runtime';
export const parseInitFromOptions = (options: BackendSrvRequest): RequestInit => {
@ -93,7 +93,7 @@ export const parseBody = (options: BackendSrvRequest, isAppJson: boolean) => {
return options.data;
}
return isAppJson ? safeStringifyValue(options.data) : new URLSearchParams(options.data);
return isAppJson ? JSON.stringify(options.data) : new URLSearchParams(options.data);
};
export async function parseResponseBody<T>(