Skip to content

Commit 44186f3

Browse files
committed
fix(codecatalyst): update API logging
Problem: Logging old headers like "x-amzn-remapped-content-length" and "x-request-id" which are no longer relevant (beta-only). This adds noise to the logs. 2023-05-02 12:05:03 [ERROR]: API request failed: listSourceRepositories params: { … } error: { … } headers: { 'x-amz-apigw-id': undefined, 'x-amz-cf-id': 'SLJcHZEtwv34S7MqZFALNP0vHNFRagHOnMhgq2MU4bqZR7mgObDhsw==', 'x-amz-cf-pop': 'DUB2-C1', 'x-amzn-remapped-content-length': undefined, 'x-amzn-remapped-x-amzn-requestid': undefined, 'x-amzn-requestid': 'b30d58ba-0a2e-45b1-b042-392c2f3eb950', 'x-amzn-served-from': 'eu-west-1', 'x-amzn-trace-id': undefined, 'x-cache': 'Error from cloudfront', 'x-request-id': undefined } Solution: Update the logging routine.
1 parent bb40b22 commit 44186f3

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/shared/clients/codecatalystClient.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
ListSourceRepositoriesItems,
3030
} from 'aws-sdk/clients/codecatalyst'
3131

32-
// REMOVE ME SOON: only used for development
3332
interface CodeCatalystConfig {
3433
readonly region: string
3534
readonly endpoint: string
@@ -237,19 +236,16 @@ class CodeCatalystClientInternal {
237236
const logHeaders = {}
238237
// Selected headers which are useful for logging.
239238
const logHeaderNames = [
240-
// 'access-control-expose-headers',
241-
// 'cache-control',
242-
// 'strict-transport-security',
243-
'x-amz-apigw-id',
244-
'x-amz-cf-id',
245-
'x-amz-cf-pop',
246-
'x-amzn-remapped-content-length',
247-
'x-amzn-remapped-x-amzn-requestid',
248239
'x-amzn-requestid',
249-
'x-amzn-served-from',
250240
'x-amzn-trace-id',
241+
'x-amzn-served-from',
251242
'x-cache',
252-
'x-request-id', // <- Request id for caws/fusi!
243+
'x-amz-cf-id',
244+
'x-amz-cf-pop',
245+
// 'access-control-expose-headers',
246+
// 'cache-control',
247+
// 'strict-transport-security',
248+
// 'x-amz-apigw-id',
253249
]
254250
if (allHeaders && Object.keys(allHeaders).length > 0) {
255251
for (const k of logHeaderNames) {
@@ -260,10 +256,7 @@ class CodeCatalystClientInternal {
260256
// Stack is noisy and useless in production.
261257
const errNoStack = { ...e }
262258
delete errNoStack.stack
263-
// Remove confusing "requestId" field (= "x-amzn-requestid" header)
264-
// because for caws/fusi, "x-request-id" is more relevant.
265-
// All of the various request-ids can be found in the logged headers.
266-
delete errNoStack.requestId
259+
delete errNoStack.requestId // redundant (= "x-amzn-requestid" header).
267260

268261
if (r.operation || r.params) {
269262
log.error(

0 commit comments

Comments
 (0)