You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
node: serve_stream paid-delivery rejections increment no metric — refused streams invisible to operators #876
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.
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
respond_error in crates/node/src/handlers/client.rs already receives the StreamError variant; that's the right central hook. Steps:
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.
In respond_error, match on StreamError → reason string and call self.metrics.serve_stream_rejected.with_label_values(&[reason]).inc().
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).
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
Activity
github-actions commentedon Jun 10, 2026
🎯 Triage report
This issue identifies an operator observability gap: every rejection branch in
serve_streamemits atracing::warn!but increments no metric, making refused paid-delivery streams completely invisible to dashboards and alerting. The handler already holdsself.metricsand 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 aserve_stream_rejected{reason}counter call insiderespond_error.📊 Assessment
mediumadded (existing:bug,technical,rust)respond_error), clearStreamError→label mapping, well-defined success criteria across all 6 branches🔗 Similar issues
unknown-channel NotFoundbranch that is itself one of the six uninstrumented branches here. This issue is the natural follow-on: fix(node): reject unknown payment channel before serving any bytes (#848) #875 stopped serving the free bytes but left the refusal signal dark.💡 Notes and suggestions
Fix approach (as described in the issue):
respond_errorincrates/node/src/handlers/client.rsalready receives theStreamErrorvariant; that's the right central hook. Steps:serve_stream_rejectedcounter tocrates/node/src/metrics.rswith areasonlabel. Reason values can mirrorStreamErrorvariants:evicted_since_probe,not_found_pull,internal_error,blob_too_large,unknown_channel,owner_mismatch.respond_error, match onStreamError→ reason string and callself.metrics.serve_stream_rejected.with_label_values(&[reason]).inc().:565, ~:590, ~:613, ~:629, ~:647, ~:661) all route throughrespond_error(or add direct increments for any that don't).StreamErrorvariants.Anti-panic note: The workspace-wide
clippy::indexing_slicingdeny 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— theunknown_channelreason in particular is the signal for detecting channel-hammering abuse that was previously undetectable.Sub-tasks:
serve_stream_rejectedcounter (withreasonlabel) inmetrics.rsrespond_errorwithStreamError→label mappingrespond_error(or add direct increments)Add this agentic workflows to your repo
To install this agentic workflow, run
docs(node): sharpen serve_stream reject-counter comments (#876)
feat(node): meter refused serve_stream paid-delivery requests (#876) (#…