Skip to content

fix: preserve provider stream error details in daemon traces - #1838

Merged
willkill07 merged 1 commit into
NVIDIA:mainfrom
mnajafian-nv:fix/daemon-stream-error-details
Nov 25, 2026
Merged

willkill07 merged 1 commit into
NVIDIA:mainfrom
mnajafian-nv:fix/daemon-stream-error-details

Conversation

@mnajafian-nv

@mnajafian-nv mnajafian-nv commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Overview

When a provider sends an error during a streamed call through the daemon, Relay
marks the call as failed but records provider response observation was truncated.
The provider's error code and message are lost.

This PR preserves the provider's error details in the trace when response delivery
completes. For example, server_error: Generation failed stays visible instead of
being replaced by the truncation message.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

Pass errors from the existing stream validators into the final trace status.
Parser and collector failures use generic messages to keep raw response data out
of diagnostics. Existing transport, cancellation, and capture-limit handling is
preserved, and invalid response aggregates remain omitted.

Tests cover provider errors, delivery of trailing bytes, and parser and collector
messages that omit raw response data.

Validation: Rust tests, Clippy, formatting, and documentation checks passed.

Where should the reviewer start?

ObservationReceiver::finish_stream and finish_inner in
crates/cli/src/daemon/worker/managed.rs, followed by the stream observation
tests in crates/cli/tests/coverage/daemon/worker_managed_tests.rs.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

Summary by CodeRabbit

  • Bug Fixes

    • Streaming observations now distinguish provider-reported failures from malformed or incomplete stream data, with clearer status descriptions.
    • Malformed stream payloads are not exposed in error descriptions, and invalid aggregates are omitted. Response bytes continue to be forwarded unchanged.
  • Documentation

    • Updated OpenTelemetry guidance to describe how streaming validation failures and collection errors appear in span status descriptions.

Keep the provider failure reason in daemon span status descriptions.

Signed-off-by: mnajafian-nv <[email protected]>
@mnajafian-nv
mnajafian-nv requested review from a team as code owners November 25, 2026 00:12
@github-actions github-actions Bot added size:S PR is small Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code labels Nov 25, 2026
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The daemon worker now propagates stream-processing errors and records them in observation status. Tests and documentation cover provider errors, malformed SSE, collection failures, payload-safe descriptions, and response-byte forwarding.

Changes

Daemon stream observation handling

Layer / File(s) Summary
Stream finalization and error propagation
crates/cli/src/daemon/worker/managed.rs
finish_stream propagates processing errors and uses fixed internal messages for malformed SSE and collection failures. finish_inner records stream errors and marks completed observations with stream errors as truncated.
Stream behavior tests and documentation
crates/cli/tests/coverage/daemon/worker_managed_tests.rs, docs/configure-plugins/observability/opentelemetry.mdx
Tests cover provider error details, malformed SSE, and collection failures without exposing payload contents. Documentation describes validation status, omitted invalid aggregates, and unchanged response-byte forwarding.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: Minimal · up to a0aed

This change keeps provider error details visible in daemon trace status for streamed calls while avoiding raw response data in error descriptions. Response delivery is unchanged. No actionable merge-blocking risk was identified.

Security architecture risk: Low · up to a0aed

Completed daemon calls can now put provider-supplied error text into traces where they previously recorded a generic failure. That improves diagnostics, but if a provider includes sensitive content in an error message, trace readers may see it unless it is redacted. Client response delivery is unchanged.

Retained concerns

  • Low · security · inferred: Completed daemon observations now publish provider-supplied error codes or types and messages as span status text. The worker does not redact or bound those fields separately, so provider errors that echo sensitive request or response data can expose it to configured telemetry consumers unless an event sanitizer or downstream control removes it.
Security review details

Security Blast Radius

  • inferred — A provider or upstream intermediary controlling a recognized stream error can influence trace status for the affected calls when delivery completes. The change reaches existing subscribers and any configured trace destination; it does not grant the sender read access to traces.

Trust Boundaries and Controls

  • observed — Omitting the response aggregate does not omit error status metadata. The runtime supplies configured event sanitizers to publication, and OpenTelemetry reads status separately from its attribute projection.

Resilience and Maintainability Implications

  • observed — The first delivery terminal state wins. Finalization waits for that state within the existing timeout: transport failure takes precedence, cancellation does not publish a validator failure, and stream errors or capture truncation suppress the aggregate. Capture loss visible before receiver close suppresses the stream diagnostic; later capture loss can coexist with a completed-stream error but still suppresses the aggregate.

Hardening Proposals

  • proposed — Keep a bounded, recognized provider error code in span status by default, and include free-form provider messages only under an explicit telemetry policy that redacts status text before publication.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title uses the Conventional Commits format with the allowed type "fix", is 60 characters long, has no trailing period, and describes the main change: preserving provider stream error details in da…
Description check Passed The description follows the repository template. It includes the Overview with both checklist items marked, the Details section explaining the change and tests, the reviewer starting points in managed…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title uses the Conventional Commits format with the allowed type "fix", is 60 characters long, has no trailing period, and describes the main change: preserving provider stream error details in daemon traces, which matches the raw summary and PR objectives.

Full details: Description check

Explanation

The description follows the repository template. It includes the Overview with both checklist items marked, the Details section explaining the change and tests, the reviewer starting points in managed.rs and the worker_managed_tests.rs file, and a Related Issues entry that uses the 'Relates to' keyword. The author also reports validation results. The description does not include the template's 'Closes #' bullet, but it uses an allowed keyword, so the template is effectively satisfied.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7400b8d and a0aed14.

Files selected for processing: 3

  • crates/cli/src/daemon/worker/managed.rs
  • crates/cli/tests/coverage/daemon/worker_managed_tests.rs
  • docs/configure-plugins/observability/opentelemetry.mdx

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Recent review details

Context from checks skipped due to timeout: 15

  • GitHub Check: CodeRabbit
  • GitHub Check: Rust / Package (linux-amd64)
  • GitHub Check: Rust / Package (windows-amd64)
  • GitHub Check: Rust / Package (linux-musl-amd64)
  • GitHub Check: Rust / Package (linux-arm64)
  • GitHub Check: Rust / Test (windows-amd64)
  • GitHub Check: Rust / Test (macos-arm64)
  • GitHub Check: Rust / Test (linux-arm64)
  • GitHub Check: Rust / Package (linux-musl-arm64)
  • GitHub Check: Rust / Package (macos-arm64)
  • GitHub Check: Rust / Test (linux-amd64)
  • GitHub Check: Rust / Package (windows-arm64)
  • GitHub Check: Rust / Test (windows-arm64)
  • GitHub Check: Check / Run
  • GitHub Check: Preview docs
Additional context used

Code guidelines: 4

.agents/skills/contribute-docs/SKILL.md — configured
.agents/skills/maintain-observability/SKILL.md — configured
AGENTS.md — configured
.agents/skills/review-doc-style/SKILL.md — configured
Path-based instructions: 6

Review documentation for technical accuracy against the current API, command correctness, and consistency across language bindings.

CodeRabbit configuration file

Files:

  • docs/configure-plugins/observability/opentelemetry.mdx
Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

CodeRabbit configuration file

Files:

  • crates/cli/tests/coverage/daemon/worker_managed_tests.rs
Source excerpt: In MDX files, top-of-file comments must use JSX comment delimiters: `{/*` to open and `*/}` to close.

CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Files:

  • docs/configure-plugins/observability/opentelemetry.mdx
Source excerpt: Core event model and emitted fields `crates/core/src/observability/atif.rs` `crates/core/src/observability/otel.rs` `crates/core/src/observability/openinference.rs` FFI and binding-native wrappers where the config or lifecyc...

CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)

Files:

  • docs/configure-plugins/observability/opentelemetry.mdx
Source excerpt: Update public documentation and examples when public behavior, package names, supported bindings, or documented workflows change.

CodeRabbit inference engine (AGENTS.md)

Files:

  • docs/configure-plugins/observability/opentelemetry.mdx
Source excerpt: Verify MDX files use JSX delimiters for top-of-file SPDX comments.

CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)

Files:

  • docs/configure-plugins/observability/opentelemetry.mdx
Additional comments: 3

crates/cli/src/daemon/worker/managed.rs: 1

1467-1470: LGTM!

Also applies to: 1473-1478, 1482-1482, 1514-1514, 1542-1546, 1561-1563, 1568-1594

crates/cli/tests/coverage/daemon/worker_managed_tests.rs: 1

358-409: LGTM!

Also applies to: 433-458, 460-467, 476-485, 3393-3397

docs/configure-plugins/observability/opentelemetry.mdx: 1

1348-1352: LGTM!

@mnajafian-nv mnajafian-nv self-assigned this Nov 25, 2026
@mnajafian-nv mnajafian-nv added this to the 1.0 milestone Nov 25, 2026
@github-actions

Copy link
Copy Markdown

@willkill07
willkill07 enabled auto-merge (squash) November 25, 2026 00:26
@willkill07
willkill07 merged commit 4a8c77b into NVIDIA:main Nov 25, 2026
47 checks passed
@codecov

codecov Bot commented Nov 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.83%. Comparing base (7400b8d) to head (a0aed14).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/cli/src/daemon/worker/managed.rs 92.59% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1838   +/-   ##
=======================================
  Coverage   93.83%   93.83%           
=======================================
  Files         556      556           
  Lines      175087   175098   +11     
  Branches      236      236           
=======================================
+ Hits       164292   164303   +11     
  Misses      10794    10794           
  Partials        1        1           
Components Coverage Δ
Rust Runtime 96.12% <ø> (-0.01%) ⬇️
Shared DTO Types 97.75% <ø> (+0.08%) ⬆️
CLI 91.57% <92.59%> (+0.01%) ⬆️
Go Binding 91.16% <ø> (ø)
Python Binding 94.46% <ø> (ø)
Node Binding 99.25% <ø> (ø)
Dynamic Plugin SDKs 94.53% <ø> (+0.01%) ⬆️
Files with missing lines Coverage Δ
crates/cli/src/daemon/worker/managed.rs 94.85% <92.59%> (-0.04%) ⬇️

... and 10 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7400b8d...a0aed14. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mnajafian-nv
mnajafian-nv deleted the fix/daemon-stream-error-details branch November 25, 2026 01:00

This branch was previously deployed

1 inactive deployment
fern — a0aed142 Deployed Nov 25, 2026 by willkill07 via Clean up docs preview #7781
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code size:S PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants