Skip to content

Commit 4f2a662

Browse files
committed
fix: address CodeRabbit review feedback
1 parent c916e41 commit 4f2a662

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

packages/cli/src/cli/localizer/explicit.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,10 @@ function createAiSdkLocalizer(params: {
284284
? `${response.text.slice(0, 500)}…`
285285
: response.text;
286286
console.error(
287-
`Failed to parse response from Lingo.dev. Response snippet: ${snippet}`,
287+
`Failed to parse response from ${params.id}. Response snippet: ${snippet}`,
288288
);
289289
throw new Error(
290-
`Failed to parse response from Lingo.dev: ${e2} (Snippet: ${snippet})`,
290+
`Failed to parse response from ${params.id}: ${e2} (Snippet: ${snippet})`,
291291
);
292292
}
293293
let finalResult: Record<string, any> = {};
@@ -313,6 +313,13 @@ function createAiSdkLocalizer(params: {
313313
`Failed to parse nested JSON response: ${e} (Snippet: ${result.data.slice(0, 100)}...)`,
314314
);
315315
}
316+
} else {
317+
console.error(
318+
`Unexpected response format - no JSON object found. Snippet: ${String(result.data).slice(0, 100)}...`,
319+
);
320+
throw new Error(
321+
`Unexpected response format from ${params.id} - no JSON object found in response`,
322+
);
316323
}
317324
}
318325

@@ -335,12 +342,12 @@ function createAiSdkLocalizer(params: {
335342
* @returns An array of payload chunks
336343
*/
337344
function extractPayloadChunks(
338-
payload: Record<string, string>,
345+
payload: Record<string, any>,
339346
batchSize?: number,
340-
): Record<string, string>[] {
347+
): Record<string, any>[] {
341348
const idealBatchItemSize = 250;
342-
const result: Record<string, string>[] = [];
343-
let currentChunk: Record<string, string> = {};
349+
const result: Record<string, any>[] = [];
350+
let currentChunk: Record<string, any> = {};
344351
let currentChunkItemCount = 0;
345352

346353
const payloadEntries = Object.entries(payload);

packages/cli/src/cli/processor/basic.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ export function createBasicTranslator(
9292
/**
9393
* Extract payload chunks based on the ideal chunk size
9494
* @param payload - The payload to be chunked
95-
* @param batchSize - Max number of keys per chunk (default: 25)
95+
* @param batchSize - Max number of keys per chunk
9696
* @returns An array of payload chunks
9797
*/
9898
function extractPayloadChunks(
99-
payload: Record<string, string>,
99+
payload: Record<string, any>,
100100
batchSize?: number,
101-
): Record<string, string>[] {
101+
): Record<string, any>[] {
102102
const idealBatchItemSize = 250;
103-
const result: Record<string, string>[] = [];
104-
let currentChunk: Record<string, string> = {};
103+
const result: Record<string, any>[] = [];
104+
let currentChunk: Record<string, any> = {};
105105
let currentChunkItemCount = 0;
106106

107107
const payloadEntries = Object.entries(payload);

0 commit comments

Comments
 (0)