azdo-cli 0.19.0-feature-037-api-error-surfacing.699 → 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.
Files changed (2) hide show
  1. package/dist/index.js +8 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -502,7 +502,9 @@ function describeFailureBody(body, contentType) {
502
502
  return null;
503
503
  }
504
504
  const redacted = redactBody(trimmed) ?? trimmed;
505
- return truncateDetail(renderErrorFields(redacted) ?? redacted.slice(0, MAX_RAW_BODY_CHARS));
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
- const body = failureBodies.get(response);
576
- throw new Error(body === void 0 ? "NOT_FOUND" : `NOT_FOUND | url=${url} | body=${body}`);
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");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azdo-cli",
3
- "version": "0.19.0-feature-037-api-error-surfacing.699",
3
+ "version": "0.19.0-feature-037-api-error-surfacing.701",
4
4
  "description": "Azure DevOps CLI tool",
5
5
  "type": "module",
6
6
  "bin": {