Skip to content

fix(middleware): preserve HTTP request failure causes - #4145

Merged
pimlock merged 2 commits into
mainfrom
fix/middleware-request-failure-causes-20261002
Dec 1, 2026
Merged

pimlock merged 2 commits into
mainfrom
fix/middleware-request-failure-causes-20261002

Conversation

@shiju-nv

@shiju-nv shiju-nv commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A remote service returning DEADLINE_EXCEEDED and an OpenShell stage timeout used to produce the same request outcome. HTTP middleware now keeps the cause alongside the diagnostic message. The relay also records how far a live request got when an upstream write failed.

Related Issue

Part of #4144.

Changes

  • Preserve the failure cause through request handling, even when all recorded stages succeeded. Explicit denials remain separate from failures.
  • Mark delivery as started on the first upstream write attempt and complete after the final flush succeeds. A partial write followed by an error stays marked as started.

Testing

  • Checks appropriate to the affected code and behavior pass
  • Unit tests added/updated (if applicable)
  • E2E tests added/updated (if applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

@github-actions

Copy link
Copy Markdown

This pull request has had no activity for 14 days and is now marked stale.

@github-actions github-actions Bot added the state:stale Inactive item at risk of automatic closure. label Oct 20, 2026
@shiju-nv shiju-nv added the test:e2e Requires end-to-end coverage label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Label test:e2e applied for 9a62429. Open the existing run and click Re-run all jobs to execute with the label set. The run will execute the standard E2E suite after building the required gateway, sandbox, and supervisor images once. The matching required CI gate status on this PR will flip green automatically once the run finishes.

@shiju-nv
shiju-nv force-pushed the fix/middleware-request-failure-causes-20261002 branch from 9a62429 to bd0b5ba Compare November 2, 2026 14:46
@copy-pr-bot

copy-pr-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@shiju-nv
shiju-nv removed this pull request from stack #4146 November 2, 2026 14:52
@shiju-nv
shiju-nv changed the base branch from feat/2431-streaming-request-middleware/pimlock to feat/2431-http-middleware-protocol-2/pimlock November 2, 2026 14:52
@shiju-nv
shiju-nv added this pull request to stack #5124 November 2, 2026 14:52
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

@shiju-nv

shiju-nv commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test bd0b5ba

@github-actions github-actions Bot removed the state:stale Inactive item at risk of automatic closure. label Nov 3, 2026
Base automatically changed from feat/2431-http-middleware-protocol-2/pimlock to main November 12, 2026 21:38
@pimlock
pimlock force-pushed the fix/middleware-request-failure-causes-20261002 branch from bd0b5ba to 34e7be6 Compare November 12, 2026 21:38
@purp purp added area:runtime Sandbox execution, isolation, supervision, policy enforcement, networking, and provider lifecycle. topic:documentation Architecture docs, READMEs, project website updates, and automated documentation generation. topic:extensions Extension APIs and integration points, consistent design, and external use cases. topic:observability Logs, metrics, traces, telemetry, dashboards, event correlation, and operational data export. topic:reliability High availability, recovery, retries, graceful degradation, and correctness across restarts. labels Nov 15, 2026
@github-actions

Copy link
Copy Markdown

This pull request has had no activity for 14 days and is now marked stale.

@github-actions github-actions Bot added the state:stale Inactive item at risk of automatic closure. label Nov 29, 2026
@shiju-nv
shiju-nv force-pushed the fix/middleware-request-failure-causes-20261002 branch 2 times, most recently from 143526f to 5654e97 Compare November 30, 2026 20:15
@shiju-nv
shiju-nv force-pushed the fix/middleware-request-failure-causes-20261002 branch from 5654e97 to d4b667e Compare November 30, 2026 20:33

@pimlock pimlock 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.

Thanks for picking this up. The plumbing looks careful: allow/deny and the sandbox-facing text are unchanged, no service status text leaks, and the new tests catch real regressions (removing delivery.start() or classifying a remote status as StageTimeout both fail tests). I found four things to address, with inline comments on each:

  1. Nothing reads the new failure kind or upload state, but the docs say the runtime distinguishes them. middleware_events builds OCSF only from failed and reason. reject_live_request_body (relay.rs:1221) matches Middleware { denial, failure, .. } and drops kind and delivery. deadline_scope() has no callers, and category() is used only by Display. An operator sees the same event for a remote DEADLINE_EXCEEDED as for a stage timeout. The per-invocation failure_kind on MiddlewareInvocation and HttpStageInvocation is likewise only written. Either emit the category, deadline scope and delivery state on the existing middleware events and document those fields, or drop the two docs lines until the #4144 consumer lands.
  2. The kind is derived by re-parsing reason strings. of_platform_reason duplicates HttpFailureCode::of_reason and already disagrees with it (session_capacity_exhausted is Unavailable in one and Capacity in the other). Its _ => InvalidResult fallback silently files any new reason as protocol.
  3. A service that is down is reported as a remote status. Reproduced by shutting down the test server in external_registry_attaches_same_service_under_multiple_names and evaluating again: failure_kind = RemoteStatus(Unavailable), category remote_status, the same as a live service that returns UNAVAILABLE. #4144 asks for these to be distinguishable.
  4. Two behaviours have no regression test. Changing the early-upstream-response cancel kind from Cancelled to Io still passes all network tests. Flipping the merge precedence in HttpStageDiagnostics::extend still passes all middleware and network tests.

Smaller notes:

  • status_failure now uses .expect("a status comes from a resolved stage") where the base had a non-panicking fallback. The invariant holds today, but returning binding_not_described would avoid a relay panic after a future refactor.
  • request_terminal_cause_survives_successful_stage_records tests a helper extracted only for that test, so it mostly restates the implementation.
  • A stale policy generation is reported as Cancelled. Is that how operators should read it?

@github-actions github-actions Bot removed the state:stale Inactive item at risk of automatic closure. label Dec 1, 2026
@shiju-nv
shiju-nv force-pushed the fix/middleware-request-failure-causes-20261002 branch 2 times, most recently from 812a274 to 5d3432d Compare December 1, 2026 13:10
@shiju-nv

shiju-nv commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the shutdown repro, @pimlock. I pushed the fixes. I also restored the binding_not_described fallback in status_failure and removed the conversion helper the old test exercised. When a policy reload interrupts an upload, the cause is now StalePolicyGeneration so callers can tell why it stopped.

pimlock
pimlock previously approved these changes Dec 1, 2026

@pimlock pimlock 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.

Thanks for the quick turnaround — everything from my review is resolved in 5d3432d. I checked each fix against the code: the reason-string tables are gone (with the sandbox codes unchanged), a service that is down now reports Unavailable, and the two new tests fail when the cancel kind or the merge order is changed.

@shiju-nv
shiju-nv force-pushed the fix/middleware-request-failure-causes-20261002 branch from 5d3432d to d78e7f5 Compare December 1, 2026 19:13
Carry typed causes through HTTP request middleware diagnostics. Distinguish
local deadlines, gRPC statuses, built-in errors and stale-policy cancellation
while preserving diagnostic messages and response selection.

Track live upstream writes from the first attempt through the final flush.
Retain delivery progress when a stage fails while output is still queued.

Refs #4144

Signed-off-by: Shiju <shiju@nvidia.com>
Keep platform failure causes and sandbox response codes together at the
point of failure. Distinguish transport errors from service-reported
gRPC statuses and track policy generation changes during upload.

Preserve cancellation through the final diagnostic merge. Cover service
shutdown, early upstream responses and competing causes in existing tests.

Remove the operations guide claims about deadline and upload details until
the middleware events expose them.

Refs #4144

Signed-off-by: Shiju <shiju@nvidia.com>
@shiju-nv
shiju-nv force-pushed the fix/middleware-request-failure-causes-20261002 branch from d78e7f5 to 65f4ae4 Compare December 1, 2026 19:20
@pimlock
pimlock enabled stacked auto-merge December 1, 2026 19:58
@pimlock
pimlock added this pull request to the merge queue Dec 1, 2026
Merged via the queue into main with commit 6981065 Dec 1, 2026
201 of 203 checks passed
@pimlock
pimlock deleted the fix/middleware-request-failure-causes-20261002 branch December 1, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:runtime Sandbox execution, isolation, supervision, policy enforcement, networking, and provider lifecycle. test:e2e Requires end-to-end coverage topic:documentation Architecture docs, READMEs, project website updates, and automated documentation generation. topic:extensions Extension APIs and integration points, consistent design, and external use cases. topic:observability Logs, metrics, traces, telemetry, dashboards, event correlation, and operational data export. topic:reliability High availability, recovery, retries, graceful degradation, and correctness across restarts.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants