Skip to content

fix(analytics): record batch evaluate failures in the Decision Audit - #389

Merged
prajjwalkumar17 merged 1 commit into
mainfrom
fix/audit-batch-evaluate-errors
Aug 31, 2026
Merged

fix(analytics): record batch evaluate failures in the Decision Audit#389
prajjwalkumar17 merged 1 commit into
mainfrom
fix/audit-batch-evaluate-errors

Conversation

@prajjwalkumar17

@prajjwalkumar17 prajjwalkumar17 commented Aug 31, 2026

Copy link
Copy Markdown
Member

The gap

A 4xx from /routing/evaluate/batch showed on the Hyperswitch dashboard but not in the Decision Audit.

The two evaluate endpoints disagreed about what a failure looks like:

failure counter audit event
fail_preview (/routing/evaluate) record_error(...)
fail_batch (/routing/evaluate/batch) none

fail_batch incremented API_REQUEST_COUNTER and returned. It never wrote a DomainAnalyticsEvent.

Worse than simply missing: the handler does call record_request_hit on entry, so a failed batch call appeared in the audit as an evaluation that started and never concluded — and it is counted by the call-count metric added in #387 with no matching outcome.

Five failure paths were affected: batch too large, routing config unavailable, parameter validation, resolve_active_algorithm (the batch twin of the no-active-rule 400), and algorithm-data parse.

The change

fail_batch now records the same RoutingEvaluateError event fail_preview does, and each site names its stage.

Stages carry a batch_ prefix deliberately: AnalyticsRoute has no batch variant, so batch traffic is filed under routing_evaluate. Until that is split, the stage is what distinguishes the two. Splitting the route label is intentionally not in this PR — it would move existing batch volume between labels and shift any dashboard filtering on routing_evaluate.

A whole-batch failure has no single entry to attribute, so the event is built from one representative request: the caller, the shared fallback_output and algorithm_for, and the first entry's parameters.

Verified against a live engine

Same oversized batch (51 entries, limit 50) fired at both binaries. Both returned an identical 400; only the audit differs:

merchant binary rows in analytics_domain_events
auditprobe_control current main request_hit only — the 400 left no trace
auditprobe_merchant this branch request_hit + routing_evaluate_error / batch_size_validation_failed / failure

cargo clippy and cargo fmt --check clean.

Note

The batch endpoint has no Playwright coverage at all — no spec under tests/ exercises /routing/evaluate/batch. Worth adding separately.

🤖 Generated with Claude Code

Closes #403

routing_evaluate_batch records a request hit on entry, but fail_batch only
incremented the Prometheus failure counter -- it never wrote a domain event. Every
4xx from the batch endpoint therefore showed in the audit as an evaluation that
started and never concluded, while Hyperswitch logged the failed routing event on
its own dashboard. The single endpoint has always recorded both, through
fail_preview, so the two endpoints disagreed about what a failure looks like.

fail_batch now records the same RoutingEvaluateError event, and each of the five
failure sites names its stage. The stages carry a batch_ prefix because
AnalyticsRoute has no batch variant -- batch traffic is filed under
routing_evaluate, so the stage is what tells the two apart. Splitting the route
label is a separate change, since it would move existing traffic between labels.

A whole-batch failure has no single entry to attribute, so the event is built from
one representative request: the caller, the shared fallback and algorithm_for, and
the first entry's parameters.

Verified against a live engine: an oversized batch on the current binary records
only request_hit, and with this change records request_hit plus
routing_evaluate_error/batch_size_validation_failed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 31, 2026 08:53
@prajjwalkumar17 prajjwalkumar17 self-assigned this Aug 31, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@prajjwalkumar17
prajjwalkumar17 merged commit ab88b59 into main Aug 31, 2026
18 of 19 checks passed
@prajjwalkumar17
prajjwalkumar17 deleted the fix/audit-batch-evaluate-errors branch August 31, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Batch evaluate failures leave no trace in the Decision Audit

2 participants