Skip to content

node: serve_stream paid-delivery rejections increment no metric — refused streams invisible to operators #876

Closed

Description

@thiras

Finding

Surfaced during the review of #848 / #875 (silent-failure audit of serve_stream).

Every paid-delivery reject branch in serve_stream (crates/node/src/handlers/client.rs) refuses the request with a signed StreamResponse { ok: false, error } and a tracing::warn!, but increments no metric:

The handler already holds self.metrics and exposes a rich surface (crates/node/src/metrics.rs: voucher_nonce_gap, node_pull_*, dispatch_rejected_*, …), so this is an inconsistency, not a missing dependency.

Impact

A refused paid-delivery request is invisible to operator dashboards — it exists only as a log line. An operator cannot alert on "rate of refused streams" or distinguish a misconfigured client from an abuse campaign (e.g. a peer hammering a node with unknown-channel requests).

This is the operator-side counterpart to #848's premise that refused/free egress was operationally invisible: #875 stops serving the free bytes, but the refusal itself still produces zero queryable signal. The wire-facing NotFound is deliberately lossy (it conflates blob-missing / channel-unknown / owner-mismatch to avoid leaking channel existence), so a server-side reason-labeled counter is the only place that distinction can live.

Suggested fix

Add a labeled counter (e.g. serve_stream_rejected{reason}) incremented centrally in respond_error (crates/node/src/handlers/client.rs), which already receives the StreamError and can map it to a label — retroactively instrumenting all six branches at once. Severity of the warn log is correct (external/abuse condition, not a node fault); only the missing counter needs fixing.

Refs

Activity

  1. added
    kind:bug
    rust
    on Jun 10, 2026
  2. github-actions commented on Jun 10, 2026

    @github-actions

    🎯 Triage report

    This issue identifies an operator observability gap: every rejection branch in serve_stream emits a tracing::warn! but increments no metric, making refused paid-delivery streams completely invisible to dashboards and alerting. The handler already holds self.metrics and the existing counter surface (dispatch_rejected_*, node_pull_*, etc.) makes this purely a missing increment, not a dependency problem. The fix has a precise, actionable target: instrument all six branches at once by adding a serve_stream_rejected{reason} counter call inside respond_error.

    📊 Assessment

    Dimension Value Reasoning
    Type Bug Missing instrumentation — a correct wire behavior with an invisible server-side signal
    Labels medium added (existing: bug, technical, rust) Operational visibility gap with no correctness impact; an ongoing abuse campaign (e.g. channel-hammering) would be undetectable, raising it above low
    Coding agent Suitable Single-file fix, specific hook (respond_error), clear StreamError→label mapping, well-defined success criteria across all 6 branches

    🔗 Similar issues

    💡 Notes and suggestions

    Fix approach (as described in the issue):

    respond_error in crates/node/src/handlers/client.rs already receives the StreamError variant; that's the right central hook. Steps:

    1. Add a serve_stream_rejected counter to crates/node/src/metrics.rs with a reason label. Reason values can mirror StreamError variants: evicted_since_probe, not_found_pull, internal_error, blob_too_large, unknown_channel, owner_mismatch.
    2. In respond_error, match on StreamError → reason string and call self.metrics.serve_stream_rejected.with_label_values(&[reason]).inc().
    3. Confirm the six call sites (~:565, ~:590, ~:613, ~:629, ~:647, ~:661) all route through respond_error (or add direct increments for any that don't).
    4. Add a unit test asserting the counter increments for at least two representative StreamError variants.

    Anti-panic note: The workspace-wide clippy::indexing_slicing deny means the label array must be statically sized or use a .get() approach; with_label_values(&[reason]) is fine since the slice is a literal.

    Observability note: Once landed, operators should wire a Prometheus alert on rate(serve_stream_rejected_total[5m]) > threshold — the unknown_channel reason in particular is the signal for detecting channel-hammering abuse that was previously undetectable.

    Sub-tasks:

    • Define serve_stream_rejected counter (with reason label) in metrics.rs
    • Increment in respond_error with StreamError→label mapping
    • Verify all 6 rejection branches route through respond_error (or add direct increments)
    • Unit test counter increments for key variants
    • Update any relevant runbook/monitoring docs to reference the new metric

    Generated by Agentic Triage for issue #876 · sonnet46 596.7K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  3. self-assigned this
    on Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:bugprio:mediumrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions