@@ -338,6 +338,12 @@ function fingerprintInventoryCacheKey(key: string): string {
338338 return hash . toString ( 16 ) . padStart ( 8 , "0" ) ;
339339}
340340
341+ function truncateSerializedErrorText ( value : string ) : string {
342+ return value . length > MAX_SERIALIZED_ERROR_MESSAGE_LENGTH
343+ ? `${ truncateUtf16Safe ( value , MAX_SERIALIZED_ERROR_MESSAGE_LENGTH ) } ...`
344+ : value ;
345+ }
346+
341347function redactErrorData ( value : unknown , depth = 0 ) : JsonValue | undefined {
342348 if ( value === undefined ) {
343349 return undefined ;
@@ -360,11 +366,8 @@ function redactErrorData(value: unknown, depth = 0): JsonValue | undefined {
360366 }
361367 return redacted ;
362368 }
363- if ( typeof value === "string" && value . length > 500 ) {
364- return `${ truncateUtf16Safe ( value , 500 ) } ...` ;
365- }
366369 if ( typeof value === "string" ) {
367- return value ;
370+ return truncateSerializedErrorText ( value ) ;
368371 }
369372 if ( typeof value === "bigint" ) {
370373 return value . toString ( ) ;
@@ -388,9 +391,7 @@ function sanitizeErrorMessage(message: string): string {
388391 / ( [ ? & ] [ ^ = \s " ' < > ] * (?: a p i [ _ - ] ? k e y | a u t h o r i z a t i o n | c o o k i e | c r e d e n t i a l | p a s s w o r d | s e c r e t | t o k e n | t k ) [ ^ = \s " ' < > ] * = ) [ ^ & \s " ' < > ] + / gi,
389392 "$1<redacted>" ,
390393 ) ;
391- return redacted . length > MAX_SERIALIZED_ERROR_MESSAGE_LENGTH
392- ? `${ truncateUtf16Safe ( redacted , MAX_SERIALIZED_ERROR_MESSAGE_LENGTH ) } ...`
393- : redacted ;
394+ return truncateSerializedErrorText ( redacted ) ;
394395}
395396
396397function isSensitiveErrorDataKey ( key : string ) : boolean {
0 commit comments