Skip to content

Commit cb1a59e

Browse files
jlukenoffXavier-Cliquennois
authored andcommitted
Revert URL encoding when fetching lineage (MarquezProject#2529)
* Revert URL encoding Signed-off-by: John Lukenoff <johnlukenoff@asana.com> * comment Signed-off-by: John Lukenoff <johnlukenoff@asana.com> * Add a test Signed-off-by: John Lukenoff <johnlukenoff@asana.com> --------- Signed-off-by: John Lukenoff <johnlukenoff@asana.com> Signed-off-by: Xavier-Cliquennois <Xavier-Cliquennois@users.noreply.github.com>
1 parent 9ef902f commit cb1a59e

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2018-2023 contributors to the Marquez project
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { generateNodeId } from '../../helpers/nodes'
5+
import * as requestUtils from '../../store/requests'
6+
import { getLineage } from '../../store/requests/lineage'
7+
8+
describe('getLineage function', () => {
9+
let spy: jest.SpyInstance<Promise<any>, [string, requestUtils.IParams, string]>
10+
let testResult: Promise<any>
11+
12+
beforeEach(() => {
13+
spy = jest.spyOn(requestUtils, 'genericFetchWrapper').mockImplementation(() => {})
14+
testResult = getLineage('JOB', 'foo', 'bar', 0)
15+
})
16+
17+
it('does not url-encode query params', () => {
18+
const expectedNodeId = generateNodeId('JOB', 'foo', 'bar')
19+
const actualParamString = spy.mock.lastCall[0].split('?')
20+
expect(actualParamString.pop()!.split('&')).toContain(`nodeId=${expectedNodeId}`)
21+
})
22+
})

web/src/store/requests/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const genericErrorMessageConstructor = (functionName: string, error: APIE
88
throw `${functionName} responded with error code ${code}: ${message}. Here are the details: ${details}`
99
}
1010

11-
interface IParams {
11+
export interface IParams {
1212
method: HttpMethod
1313
body?: string
1414
}

web/src/store/requests/lineage.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ export const getLineage = async (
1212
name: string,
1313
depth: number
1414
) => {
15-
const params = new URLSearchParams({
16-
nodeId: generateNodeId(nodeType, namespace, name),
17-
depth: depth.toString()
18-
})
19-
const url = `${API_URL}/lineage/?${params.toString()}`
15+
const nodeId = generateNodeId(nodeType, namespace, name)
16+
// Node ID cannot be URL encoded
17+
const url = `${API_URL}/lineage/?nodeId=${nodeId}&depth=${depth}`
2018
return genericFetchWrapper(url, { method: 'GET' }, 'fetchLineage')
2119
}

0 commit comments

Comments
 (0)