Awesome Reviewers

Reviewer · Error Handling

Surface real failures

Many APIs (Elasticsearch refresh/bulk, Fleet bulk install, Graph HTTP calls, ingest responses) report an outer success (HTTP 200, no thrown exception) while the real outcome is embedded deeper in the response (`_shards.failed`, `errors: true` with per-item failures, a per-package error body, a 4xx/5xx status returned as `{ status, data }`). Treat the...

Instruction

Many APIs (Elasticsearch refresh/bulk, Fleet bulk install, Graph HTTP calls, ingest responses) report an outer success (HTTP 200, no thrown exception) while the real outcome is embedded deeper in the response (_shards.failed, errors: true with per-item failures, a per-package error body, a 4xx/5xx status returned as { status, data }). Treat the top-level status as insufficient: explicitly inspect these nested fields and fail/log/retry accordingly instead of letting a partially-failed operation look identical to a fully successful one. For example, don’t just check that a bulk request didn’t throw — check response.errors and each item’s error; don’t just check an HTTP call resolved — check its status code and throw on 4xx/5xx rather than returning it as data.

When you do catch an error to wrap, classify, or convert it (e.g. into a domain-specific error type, a Boom error, or before reporting to APM), keep the original error accessible — attach it as cause, preserve the underlying HTTP response/status/Retry-After, and pass the original (not just the wrapper) to tools that rely on stack/type for grouping or retry logic. Rethrow only the specific error shapes you intend to remap (e.g. a specific Boom code or message), and let anything else propagate unchanged so unrelated failures (permission errors, transient infra errors) aren’t misclassified or silently absorbed.

When aggregating results from multiple independent operations (Promise.all, loops over items), don’t let one failure hide the others: collect every error (e.g. via AggregateError or an explicit list) rather than keeping only the first rejection, and never drop a caught error with no log line — at minimum log it at debug/warn level so failures remain diagnosable even when the surrounding flow is best-effort.