fix(rapid7-insightidr): explain the process-tree 404 (v1.9.1)

Running the command on an alert reports `{"error": "HTTP 404", "detail": ""}`.
The API returns 404 with an empty body, so the operator is told a number and
nothing else — and cannot tell a normal answer from a fault.

It is usually normal, and the URL is not at fault: it is built exactly as
get_alert_evidence builds its own, which works. Rapid7 uses the same 404 for
three unrelated situations and does not distinguish them:

  - the alert is not an endpoint detection, so no tree exists. This is the
    common case on a feed of ingress_auth, asset_auth or firewall events;

  - the tree exists in principle but was never generated. The endpoint returns
    the CACHED tree unless force_refresh is set, so an ungenerated tree answers
    404 while its data is there. Retrying with force_refresh=true is the first
    thing to try on an endpoint detection;

  - the key lacks the privilege.

All three are now named in the error, and the force_refresh input says what it
is really for rather than describing it only as a staleness control.

The ingestion path already handled this correctly — it treats 404 as "no tree"
and counts only other statuses as errors — so nothing changes there.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-08 15:56:23 +02:00
parent 1888648930
commit 2d6e097742
2 changed files with 16 additions and 3 deletions
@@ -62,6 +62,19 @@ try:
run()
except urllib.error.HTTPError as e:
detail = e.read().decode("utf-8", "replace")
if e.code == 404:
# The API returns 404 with an EMPTY body here, so without this the
# operator gets `{"error": "HTTP 404", "detail": ""}` and no way to tell
# a normal answer from a fault. It is usually normal: only an endpoint
# detection has a tree at all.
detail = (detail or "no process tree for this alert. Rapid7 answers 404 for three "
"different situations and does not distinguish them: (1) the alert is not "
"an endpoint detection, so no tree exists — check triggering_event_type "
"with rapid7-insight-idr-get-alert, and expect no tree for ingress_auth, "
"asset_auth, unparsed or firewall events; (2) the tree was never generated "
"— this endpoint returns the CACHED tree unless force_refresh is set, so "
"retry with force_refresh=true, which the API documents as slow; (3) the "
"API key lacks the privilege for it.")
if e.code in (401, 403):
detail += (" — the Alert Triage API (/idr/at) is only available to Managed Detection and"
" Response customers with access to the Alerts experience; a key that works on"