Skip to content

Commit f4e7e24

Browse files
authored
fix(insights): transaction names with quotes break caches (#74667)
fixes #74554 The above issue was a result in the transaction duration query sending the list of transactions without the quotes escaped .
1 parent 78d3349 commit f4e7e24

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

static/app/views/insights/cache/views/cacheLandingPage.spec.tsx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,67 @@ describe('CacheLandingPage', function () {
182182
);
183183
});
184184

185+
it('should escape quote in transaction name', async function () {
186+
requestMocks.spanTransactionList.mockClear();
187+
requestMocks.spanTransactionList = MockApiClient.addMockResponse({
188+
url: `/organizations/${organization.slug}/events/`,
189+
method: 'GET',
190+
match: [
191+
MockApiClient.matchQuery({
192+
referrer: 'api.performance.cache.landing-cache-transaction-list',
193+
}),
194+
],
195+
body: {
196+
data: [
197+
{
198+
transaction: 'transaction with "quote"',
199+
project: 'backend',
200+
'project.id': 123,
201+
'avg(cache.item_size)': 123,
202+
'spm()': 123,
203+
'sum(span.self_time)': 123,
204+
'cache_miss_rate()': 0.123,
205+
'time_spent_percentage()': 0.123,
206+
},
207+
],
208+
meta: {
209+
fields: {
210+
transaction: 'string',
211+
project: 'string',
212+
'project.id': 'integer',
213+
'avg(cache.item_size)': 'number',
214+
'spm()': 'rate',
215+
'sum(span.self_time)': 'duration',
216+
'cache_miss_rate()': 'percentage',
217+
'time_spent_percentage()': 'percentage',
218+
},
219+
units: {},
220+
},
221+
},
222+
});
223+
224+
render(<CacheLandingPage />, {organization});
225+
226+
await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));
227+
228+
expect(requestMocks.transactionDurations).toHaveBeenCalledWith(
229+
`/organizations/${organization.slug}/events/`,
230+
expect.objectContaining({
231+
method: 'GET',
232+
query: {
233+
dataset: 'metrics',
234+
environment: [],
235+
field: ['avg(transaction.duration)', 'transaction'],
236+
per_page: 50,
237+
project: [],
238+
query: 'transaction:["transaction with \\"quote\\""]',
239+
referrer: 'api.performance.cache.landing-cache-transaction-duration',
240+
statsPeriod: '10d',
241+
},
242+
})
243+
);
244+
});
245+
185246
it('renders a list of transactions', async function () {
186247
render(<CacheLandingPage />, {organization});
187248
await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));

static/app/views/insights/cache/views/cacheLandingPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export function CacheLandingPage() {
134134
isFetching: isTransactionDurationFetching,
135135
} = useMetrics(
136136
{
137-
search: `transaction:[${transactionsList.map(({transaction}) => `"${transaction}"`).join(',')}]`,
137+
search: `transaction:[${transactionsList.map(({transaction}) => `"${transaction.replaceAll('"', '\\"')}"`).join(',')}]`,
138138
fields: [`avg(transaction.duration)`, 'transaction'],
139139
enabled: !isTransactionsListFetching && transactionsList.length > 0,
140140
},

0 commit comments

Comments
 (0)