Skip to content

feat(ipni): expose failureReason as top-level field on ipni_tracking_failed#491

Merged
SgtPooki merged 2 commits into
mainfrom
fix/ipni-tracking-failed-top-level-reason
May 4, 2026
Merged

feat(ipni): expose failureReason as top-level field on ipni_tracking_failed#491
SgtPooki merged 2 commits into
mainfrom
fix/ipni-tracking-failed-top-level-reason

Conversation

@SgtPooki
Copy link
Copy Markdown
Collaborator

Summary

  • Adds a top-level failureReason field to the ipni_tracking_failed structured log alongside the existing error: toStructuredError(error) blob
  • Lets BS / Grafana / dashboards filter and aggregate by reason class (timeout vs missing-expected-provider vs HTTP fetch error vs parse error) without JSON-extracting through error.message
  • No behavior change

Why

toStructuredError(error) nests the underlying message inside error.message, which means every BS query that wants to group by reason has to drill into the nested struct. Promoting the message to a top-level field is friction-free for operators and SPs.

Companion to #490 (which makes the underlying message carry the actual reason instead of "root CID not verified").

See dealbot#473 audit comment for the full investigation: #473 (comment)

Test plan

  • pnpm exec vitest run src/deal-addons/strategies/ipni.strategy.spec.ts -> 11/11 pass
  • No assertion regressions; failureReason is additive
  • Manual: post-deploy, BS query WHERE event = 'ipni_tracking_failed' GROUP BY failureReason should bucket failures cleanly without parsing nested fields

…failed

toStructuredError(error) only captures error.message inside a nested
error.message field, which forces BS users to JSON-extract through two
layers to filter or aggregate by failure type. Promote the underlying
message to a top-level failureReason field so operators and SPs can
group ipni_tracking_failed events by reason class without parsing the
stack-bearing error blob.

Companion to the fix in #490.
Copilot AI review requested due to automatic review settings April 28, 2026 14:44
@FilOzzy FilOzzy added this to FOC Apr 28, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Apr 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances backend IPNI failure observability by promoting the underlying failure message into a top-level failureReason field on the ipni_tracking_failed structured log event, making it easier to filter/aggregate in log analytics without nested JSON extraction.

Changes:

  • Add failureReason as a top-level field on the ipni_tracking_failed log event (derived from the caught error’s message).
  • Keep the existing error: toStructuredError(error) payload unchanged (additive change only).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/backend/src/deal-addons/strategies/ipni.strategy.ts
…lureReason

Companion to #490, which now carries the actual failure detail via
Error.cause rather than concatenating it into the outer message.
Promote cause.message to the top-level failureReason field when
present, falling back to error.message when no cause is attached
(e.g. for non-rethrown errors thrown directly inside the catch block).

Result: { failureReason: "IPNI verification timed out after 60000ms" }
instead of { failureReason: "IPNI verification failed for deal X:
root CID not verified" }.
@SgtPooki SgtPooki self-assigned this Apr 28, 2026
@SgtPooki SgtPooki moved this from 📌 Triage to ⌨️ In Progress in FOC Apr 28, 2026
@SgtPooki SgtPooki moved this from ⌨️ In Progress to 🔎 Awaiting review in FOC Apr 28, 2026
@github-project-automation github-project-automation Bot moved this from 🔎 Awaiting review to ✔️ Approved by reviewer in FOC May 4, 2026
@SgtPooki SgtPooki merged commit dcda80e into main May 4, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FOC May 4, 2026
@SgtPooki SgtPooki deleted the fix/ipni-tracking-failed-top-level-reason branch May 4, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

4 participants