@@ -263,6 +263,48 @@ describe('log-cleaner', () => {
263263 } ) ;
264264 } ) ;
265265
266+ it ( 'should handle error context with circular reference' , ( ) => {
267+ const error = new Error ( 'test error' ) ;
268+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
269+ const circularContext : any = { key : 'value' } ;
270+ circularContext . circular = circularContext ;
271+ Object . assign ( error , circularContext ) ;
272+
273+ const logEvent = {
274+ event : error ,
275+ } ;
276+
277+ const result = cleanLogEvent ( logEvent ) ;
278+
279+ expect ( result . event . errorContext ) . toMatch (
280+ / ^ L o g g e r e r r o r - c o u l d n o t s t r i n g i f y o b j e c t \. / ,
281+ ) ;
282+ } ) ;
283+
284+ it ( 'should handle ApplicationError params with circular reference' , ( ) => {
285+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
286+ const circularParams : any = {
287+ message : 'test' ,
288+ data : { } ,
289+ } ;
290+ circularParams . data . circular = circularParams ;
291+
292+ const appError = new ApplicationError ( {
293+ code : ErrorCode . ENTITY_NOT_FOUND ,
294+ params : circularParams ,
295+ } ) ;
296+
297+ const logEvent = {
298+ event : appError ,
299+ } ;
300+
301+ const result = cleanLogEvent ( logEvent ) ;
302+
303+ expect ( result . event . errorParams ) . toMatch (
304+ / ^ L o g g e r e r r o r - c o u l d n o t s t r i n g i f y o b j e c t \. / ,
305+ ) ;
306+ } ) ;
307+
266308 it ( 'should flatten error in correct fields by prefix' , ( ) => {
267309 const logEvent = {
268310 event : {
0 commit comments