-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[server] fix more revealing BB error logs (#20402)
* [server] fix more revealing BB error logs * MOORe * Introduce `BitbucketHttpError` to redact more effectively * Make it work? * comment fix * 💶
- Loading branch information
1 parent
8054819
commit c4d64c0
Showing
5 changed files
with
54 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright (c) 2024 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License.AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { RequestOptions } from "bitbucket/src/plugins/register-endpoints/types"; | ||
|
||
// For some reason we can't import HTTPError from bitbucket/src/error/types. This is only a subset of the actual class | ||
export abstract class HTTPError extends Error { | ||
public request: RequestOptions | undefined; | ||
} | ||
|
||
export function handleBitbucketError(err: Error): Error { | ||
if (err.name !== "HTTPError") { | ||
return err; | ||
} | ||
|
||
const httpError = err as HTTPError; | ||
if (httpError.request?.headers.authorization) { | ||
httpError.request.headers.authorization = "<redacted>"; | ||
} | ||
|
||
return httpError; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters