azdo-cli 0.19.0-feature-037-api-error-surfacing.697 → 0.19.0-feature-037-api-error-surfacing.701
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +10 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -81,8 +81,8 @@ function redactUrl(url) {
|
|
|
81
81
|
var SECRET_ASSIGNMENT = String.raw`["']?\s*[:=]\s*["']?)[^"'\s,;&}]+`;
|
|
82
82
|
var SECRET_IN_TEXT = [
|
|
83
83
|
[/\b(Bearer|Basic)\s+[\w.~+/=-]{8,}/gi, `$1 ${REDACTED}`],
|
|
84
|
-
[new RegExp(`(
|
|
85
|
-
[new RegExp(`(
|
|
84
|
+
[new RegExp(String.raw`(\b(?:access|refresh|api)[_-]?(?:token|key)\b${SECRET_ASSIGNMENT}`, "gi"), `$1${REDACTED}`],
|
|
85
|
+
[new RegExp(String.raw`(\b(?:token|pat|password|secret)\b${SECRET_ASSIGNMENT}`, "gi"), `$1${REDACTED}`],
|
|
86
86
|
[/\beyJ[A-Za-z0-9._~+/=-]{20,}/g, REDACTED],
|
|
87
87
|
[/\b(?=[A-Za-z0-9]*\d)(?=[A-Za-z0-9]*[A-Za-z])[A-Za-z0-9]{40,}\b/g, REDACTED]
|
|
88
88
|
];
|
|
@@ -502,7 +502,9 @@ function describeFailureBody(body, contentType) {
|
|
|
502
502
|
return null;
|
|
503
503
|
}
|
|
504
504
|
const redacted = redactBody(trimmed) ?? trimmed;
|
|
505
|
-
|
|
505
|
+
const fields = renderErrorFields(redacted);
|
|
506
|
+
if (fields !== null) return truncateDetail(fields);
|
|
507
|
+
return truncateDetail(redactText(redacted).slice(0, MAX_RAW_BODY_CHARS));
|
|
506
508
|
}
|
|
507
509
|
function truncateDetail(detail) {
|
|
508
510
|
const collapsed = redactText(detail).replace(/\s+/g, " ").trim();
|
|
@@ -545,12 +547,12 @@ function writeTraceEntry(writer, url, init, response, responseBody) {
|
|
|
545
547
|
async function traceResponse(url, init, response) {
|
|
546
548
|
const writer = getActiveTraceWriter();
|
|
547
549
|
if (!writer) return null;
|
|
548
|
-
let responseBody =
|
|
550
|
+
let responseBody = null;
|
|
549
551
|
try {
|
|
550
552
|
responseBody = await response.clone().text();
|
|
551
553
|
} catch {
|
|
552
554
|
}
|
|
553
|
-
writeTraceEntry(writer, url, init, response, responseBody);
|
|
555
|
+
writeTraceEntry(writer, url, init, response, responseBody ?? "");
|
|
554
556
|
return responseBody;
|
|
555
557
|
}
|
|
556
558
|
async function fetchWithErrors(url, init) {
|
|
@@ -572,8 +574,9 @@ async function fetchWithErrors(url, init) {
|
|
|
572
574
|
if (response.status === 401) throw new Error(withDetail("AUTH_FAILED", failureDetail));
|
|
573
575
|
if (response.status === 403) throw new Error(withDetail("PERMISSION_DENIED", failureDetail));
|
|
574
576
|
if (response.status === 404) {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
+
throw new Error(
|
|
578
|
+
failureDetail === null ? "NOT_FOUND" : `NOT_FOUND | url=${redactUrl(url)} | body=${failureDetail}`
|
|
579
|
+
);
|
|
577
580
|
}
|
|
578
581
|
if (contentType.toLowerCase().startsWith("text/html")) {
|
|
579
582
|
throw new Error("AUTH_FAILED");
|