@@ -28,6 +28,8 @@ import { generateUuid } from '../../../util/vs/base/common/uuid';
2828import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation' ;
2929import { isBYOKModel } from '../../byok/node/openAIEndpoint' ;
3030import { EXTENSION_ID } from '../../common/constants' ;
31+ import { IAuthenticationService } from '../../../platform/authentication/common/authentication' ;
32+ import { escapeRegExpCharacters } from '../../../util/vs/base/common/strings' ;
3133
3234export interface IMadeChatRequestEvent {
3335 readonly messages : Raw . ChatMessage [ ] ;
@@ -81,6 +83,7 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
8183 @ITelemetryService private readonly _telemetryService : ITelemetryService ,
8284 @IRequestLogger private readonly _requestLogger : IRequestLogger ,
8385 @ILogService private readonly _logService : ILogService ,
86+ @IAuthenticationService private readonly _authenticationService : IAuthenticationService ,
8487 @IInstantiationService private readonly _instantiationService : IInstantiationService ,
8588 @IConversationOptions options : IConversationOptions ,
8689 ) {
@@ -710,32 +713,42 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
710713 this . _logService . error ( errorsUtil . fromUnknown ( err ) , `Error on conversation request` ) ;
711714 this . _telemetryService . sendGHTelemetryException ( err , 'Error on conversation request' ) ;
712715 const errorDetail = fetcher . getUserMessageForFetcherError ( err ) ;
716+ const scrubbedErrorDetail = this . scrubErrorDetail ( errorDetail ) ;
713717 if ( fetcher . isInternetDisconnectedError ( err ) ) {
714718 return {
715719 type : ChatFetchResponseType . NetworkError ,
716720 reason : `It appears you're not connected to the internet, please check your network connection and try again.` ,
717- reasonDetail : errorDetail ,
721+ reasonDetail : scrubbedErrorDetail ,
718722 requestId : requestId ,
719723 serverRequestId : undefined ,
720724 } ;
721725 } else if ( fetcher . isFetcherError ( err ) ) {
722726 return {
723727 type : ChatFetchResponseType . NetworkError ,
724728 reason : errorDetail ,
725- reasonDetail : errorDetail ,
729+ reasonDetail : scrubbedErrorDetail ,
726730 requestId : requestId ,
727731 serverRequestId : undefined ,
728732 } ;
729733 } else {
730734 return {
731735 type : ChatFetchResponseType . Failed ,
732736 reason : 'Error on conversation request. Check the log for more details.' ,
733- reasonDetail : errorDetail ,
737+ reasonDetail : scrubbedErrorDetail ,
734738 requestId : requestId ,
735739 serverRequestId : undefined ,
736740 } ;
737741 }
738742 }
743+
744+ private scrubErrorDetail ( errorDetail : string ) {
745+ const username = this . _authenticationService . copilotToken ?. username ;
746+ if ( ! username ) {
747+ return errorDetail ;
748+ }
749+ const regex = new RegExp ( escapeRegExpCharacters ( username ) , 'ig' ) ;
750+ return errorDetail . replaceAll ( regex , '<login>' ) ;
751+ }
739752}
740753
741754/**
0 commit comments