Skip to content

Commit 5d6c74d

Browse files
committed
refactor: remove verbose error logging from Bedrock provider
1 parent 72128ff commit 5d6c74d

File tree

1 file changed

+1
-96
lines changed

1 file changed

+1
-96
lines changed

src/api/providers/bedrock.ts

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,92 +1266,7 @@ Please check:
12661266
const modelConfig = this.getModel()
12671267
templateVars.modelId = modelConfig.id
12681268
templateVars.contextWindow = String(modelConfig.info.contextWindow || "unknown")
1269-
1270-
// Extract error codes and identifiers for verbose display
1271-
const errorCodes: string[] = []
1272-
const errorMeta: string[] = []
1273-
1274-
// HTTP Status Code
1275-
if ((error as any).status) {
1276-
errorCodes.push(`HTTP ${(error as any).status}`)
1277-
}
1278-
if ((error as any).$metadata?.httpStatusCode) {
1279-
errorCodes.push(`HTTP ${(error as any).$metadata.httpStatusCode}`)
1280-
}
1281-
1282-
// AWS Error Codes
1283-
if (error.name && error.name !== "Error") {
1284-
errorCodes.push(`AWS ${error.name}`)
1285-
}
1286-
if ((error as any).__type) {
1287-
errorCodes.push(`Type ${(error as any).__type}`)
1288-
}
1289-
1290-
// Request ID for debugging
1291-
if ((error as any).$metadata?.requestId) {
1292-
errorMeta.push(`Request ID: ${(error as any).$metadata.requestId}`)
1293-
}
1294-
if ((error as any).requestId) {
1295-
errorMeta.push(`Request ID: ${(error as any).requestId}`)
1296-
}
1297-
1298-
// Extended Request ID (S3/CloudFront style)
1299-
if ((error as any).$metadata?.extendedRequestId) {
1300-
errorMeta.push(`Extended Request ID: ${(error as any).$metadata.extendedRequestId}`)
1301-
}
1302-
1303-
// CF Request ID (CloudFront)
1304-
if ((error as any).$metadata?.cfId) {
1305-
errorMeta.push(`CloudFront ID: ${(error as any).$metadata.cfId}`)
1306-
}
1307-
1308-
// Build error code display - only include verbose details if enabled
1309-
const verboseErrorsEnabled = this.options.awsBedrockVerboseErrors ?? true // Default to true for backward compatibility
1310-
1311-
if (verboseErrorsEnabled) {
1312-
templateVars.errorCodes = errorCodes.length > 0 ? `[${errorCodes.join(", ")}]` : ""
1313-
templateVars.errorMetadata = errorMeta.length > 0 ? `\n\nDebug Info:\n${errorMeta.join("\n")}` : ""
1314-
} else {
1315-
// In non-verbose mode, only include essential error codes
1316-
templateVars.errorCodes = ""
1317-
templateVars.errorMetadata = ""
1318-
}
1319-
1320-
// Format error details
1321-
const errorDetails: Record<string, any> = {}
1322-
Object.getOwnPropertyNames(error).forEach((prop) => {
1323-
if (prop !== "stack") {
1324-
errorDetails[prop] = (error as any)[prop]
1325-
}
1326-
})
1327-
1328-
// Safely stringify error details to avoid circular references
1329-
if (verboseErrorsEnabled) {
1330-
templateVars.formattedErrorDetails = Object.entries(errorDetails)
1331-
.map(([key, value]) => {
1332-
let valueStr
1333-
if (typeof value === "object" && value !== null) {
1334-
try {
1335-
// Use a replacer function to handle circular references
1336-
valueStr = JSON.stringify(value, (k, v) => {
1337-
if (k && typeof v === "object" && v !== null) {
1338-
return "[Object]"
1339-
}
1340-
return v
1341-
})
1342-
} catch (e) {
1343-
valueStr = "[Complex Object]"
1344-
}
1345-
} else {
1346-
valueStr = String(value)
1347-
}
1348-
return `- ${key}: ${valueStr}`
1349-
})
1350-
.join("\n")
1351-
} else {
1352-
// In non-verbose mode, only include the error message
1353-
templateVars.formattedErrorDetails = ""
1354-
}
1269+
templateVars.formattedErrorDetails = ""
13551270
}
13561271

13571272
// Add context-specific template variables
@@ -1366,16 +1281,6 @@ Please check:
13661281
template = template.replace(new RegExp(`{${key}}`, "g"), value || "")
13671282
}
13681283

1369-
// Add error codes at the beginning if available
1370-
if (templateVars.errorCodes) {
1371-
template = `${templateVars.errorCodes} ${template}`
1372-
}
1373-
1374-
// Add metadata at the end if available
1375-
if (templateVars.errorMetadata) {
1376-
template = `${template}${templateVars.errorMetadata}`
1377-
}
1378-
13791284
return template
13801285
}
13811286

0 commit comments

Comments
 (0)