File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
packages/cli/src/cli/localizer Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -300,10 +300,17 @@ function createAiSdkLocalizer(params: {
300300 const index = result . data . indexOf ( "{" ) ;
301301 const lastIndex = result . data . lastIndexOf ( "}" ) ;
302302 if ( index !== - 1 && lastIndex !== - 1 ) {
303- const trimmed = result . data . slice ( index , lastIndex + 1 ) ;
304- const repaired = jsonrepair ( trimmed ) ;
305- const parsed = JSON . parse ( repaired ) ;
306- finalResult = parsed . data || parsed || { } ;
303+ try {
304+ const trimmed = result . data . slice ( index , lastIndex + 1 ) ;
305+ const repaired = jsonrepair ( trimmed ) ;
306+ const parsed = JSON . parse ( repaired ) ;
307+ finalResult = parsed . data || parsed || { } ;
308+ } catch ( e ) {
309+ console . error (
310+ `Failed to parse nested JSON response. Snippet: ${ result . data . slice ( 0 , 100 ) } ...` ,
311+ ) ;
312+ // Fallback to empty object or continue
313+ }
307314 }
308315 }
309316
You can’t perform that action at this time.
0 commit comments