@@ -104,7 +104,11 @@ export class BitbucketContextParser extends AbstractContextParser implements ICo
104104 return await this . handleNavigatorContext ( ctx , user , host , owner , repoName ) ;
105105 } catch ( e ) {
106106 span . addTags ( { contextUrl } ) . log ( { error : e } ) ;
107- log . error ( { userId : user . id } , "Error parsing Bitbucket context" , e ) ;
107+ let error = e ;
108+ if ( e . name === "HTTPError" ) {
109+ error = e . status ; // we don't want to expose the full error message since it contains credentials
110+ }
111+ log . error ( { userId : user . id } , "Error parsing Bitbucket context" , error ) ;
108112 throw e ;
109113 } finally {
110114 span . finish ( ) ;
@@ -211,7 +215,11 @@ export class BitbucketContextParser extends AbstractContextParser implements ICo
211215 } as NavigatorContext ;
212216 } catch ( e ) {
213217 span . log ( { error : e } ) ;
214- log . error ( { userId : user . id } , "Error parsing Bitbucket navigator request context" , e ) ;
218+ let error = e ;
219+ if ( e . name === "HTTPError" ) {
220+ error = e . status ; // we don't want to expose the full error message since it contains credentials
221+ }
222+ log . error ( { userId : user . id } , "Error parsing Bitbucket navigator request context" , error ) ;
215223 throw e ;
216224 } finally {
217225 span . finish ( ) ;
@@ -272,7 +280,11 @@ export class BitbucketContextParser extends AbstractContextParser implements ICo
272280 } ;
273281 } catch ( e ) {
274282 span . log ( { error : e } ) ;
275- log . error ( { userId : user . id } , "Error parsing Bitbucket pull request context" , e ) ;
283+ let error = e ;
284+ if ( e . name === "HTTPError" ) {
285+ error = e . status ; // we don't want to expose the full error message since it contains credentials
286+ }
287+ log . error ( { userId : user . id } , "Error parsing Bitbucket pull request context" , error ) ;
276288 throw e ;
277289 } finally {
278290 span . finish ( ) ;
@@ -304,7 +316,11 @@ export class BitbucketContextParser extends AbstractContextParser implements ICo
304316 } ;
305317 } catch ( e ) {
306318 span . log ( { error : e } ) ;
307- log . error ( { userId : user . id } , "Error parsing Bitbucket issue context" , e ) ;
319+ let error = e ;
320+ if ( e . name === "HTTPError" ) {
321+ error = e . status ; // we don't want to expose the full error message since it contains credentials
322+ }
323+ log . error ( { userId : user . id } , "Error parsing Bitbucket issue context" , error ) ;
308324 throw e ;
309325 } finally {
310326 span . finish ( ) ;
0 commit comments