Skip to content

Commit fceb44e

Browse files
committed
fix(core): fix incorrect pagination params in iceberg fetch
ref: #PRDCOL-181 Signed-off-by: Atef ZAAFOURI <[email protected]>
1 parent 053345c commit fceb44e

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

packages/manager/core/api/src/iceberg.ts

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { AxiosResponse } from 'axios';
22

33
import { apiClient } from './client.js';
44
import { transformTagsFiltersToQuery } from './filters.js';
5-
import { Filter, FilterComparator, FilterTypeCategories } from './types/filters.type.js';
5+
import {
6+
Filter,
7+
FilterComparator,
8+
FilterTypeCategories,
9+
} from './types/filters.type.js';
610
import {
711
IcebergFetchParamsV2,
812
IcebergFetchParamsV6,
@@ -24,7 +28,10 @@ export const appendIamTags = (
2428
return params;
2529
};
2630

27-
export function icebergFilter(comparator: FilterComparator, value: string | string[]) {
31+
export function icebergFilter(
32+
comparator: FilterComparator,
33+
value: string | string[],
34+
) {
2835
const v = encodeURIComponent(String(value || ''));
2936
switch (comparator) {
3037
case FilterComparator.Includes:
@@ -78,7 +85,7 @@ export const buildHeaders = () => {
7885
return builder;
7986
},
8087
setDisabledCache: (disableCache: boolean | undefined) => {
81-
if (disableCache) headers['Pragma'] = 'no-cache';
88+
if (disableCache) headers.Pragma = 'no-cache';
8289
return builder;
8390
},
8491
setPaginationSort: (sortBy: string | undefined, sortOrder = 'ASC') => {
@@ -94,7 +101,10 @@ export const buildHeaders = () => {
94101
.filter(({ type }) => type !== FilterTypeCategories.Tags)
95102
.map(
96103
({ comparator, key, value }) =>
97-
`${encodeURIComponent(key)}:${icebergFilter(comparator, String(value || ''))}`,
104+
`${encodeURIComponent(key)}:${icebergFilter(
105+
comparator,
106+
String(value || ''),
107+
)}`,
98108
)
99109
.join('&');
100110
if (filtersJoin) {
@@ -107,7 +117,11 @@ export const buildHeaders = () => {
107117
headers[key] = value;
108118
return builder;
109119
},
110-
setIamTags: (params: URLSearchParams, filters: Filter[] | undefined, paramName = 'iamTags') => {
120+
setIamTags: (
121+
params: URLSearchParams,
122+
filters: Filter[] | undefined,
123+
paramName = 'iamTags',
124+
) => {
111125
appendIamTags(params, filters, paramName);
112126
return builder;
113127
},
@@ -141,7 +155,11 @@ export async function fetchIcebergV2<T>({
141155
.setDisabledCache(disableCache)
142156
.setPaginationSort(sortBy, sortOrder)
143157
.setPaginationFilter(filters)
144-
.setIamTags(params, filters, route.includes('/iam/resource') ? 'tags' : 'iamTags')
158+
.setIamTags(
159+
params,
160+
filters,
161+
route.includes('/iam/resource') ? 'tags' : 'iamTags',
162+
)
145163
.build();
146164

147165
const response: AxiosResponse<T[]> = await apiClient.v2.get<T[]>(
@@ -153,7 +171,7 @@ export async function fetchIcebergV2<T>({
153171

154172
return {
155173
data: response.data,
156-
cursorNext: headers['x-pagination-cursor-next'] ?? '',
174+
cursorNext: headers['x-pagination-cursor-next'],
157175
status: response.status,
158176
};
159177
}

packages/manager/core/api/src/types/iceberg.type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ export type IcebergFetchResultV6<T> = {
3232

3333
export type IcebergFetchResultV2<T> = {
3434
data: T[];
35-
cursorNext: string;
35+
cursorNext?: string;
3636
status: number;
3737
};

0 commit comments

Comments
 (0)