Skip to content

fix(server): omit absent request-log ids instead of logging them empty (#301) - #633

Open
chethanuk wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
chethanuk:fix/request-log-absent-vs-empty-ids-301
Open

fix(server): omit absent request-log ids instead of logging them empty (#301)#633
chethanuk wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
chethanuk:fix/request-log-absent-vs-empty-ids-301

Conversation

@chethanuk

@chethanuk chethanuk commented Sep 5, 2026

Copy link
Copy Markdown

What

  • Drop .unwrap_or("") on session_id/correlation_id in RequestLogContext::emit and emit_cancelled, so an absent id omits the field instead of logging it as empty.
  • Widen the test subscriber to capture event fields (not just the message) and add a table test over absent/empty/present id shapes.

Why

The terminal request log renders session_id= for both "no session was sent" and "an empty session was sent" — an operator can't tell them apart. This is part 3 of #301; parts 1 and 2 landed in #308.

Closes #301.

Notes for reviewers

requested_model, selected_model, and error keep unwrap_or("") on purpose: emit_cancelled hardcodes selected_model = "", so those three mean "absent implies empty" by design. The only non-test producer of session_id (resolve_path) never returns Some("") today, so the empty-string test row is a regression guard rather than a live bug — the user-visible change is that an absent session stops printing session_id=.

Test plan

  • cargo test -p switchyard-server request_log — new test fails today (left: Some(""), right: None), 4 passed after the fix
  • cargo fmt --all --check
  • cargo clippy -p switchyard-server --all-targets -- -D warnings
  • cargo test --workspace — 586 passed, 0 failed, 1 ignored

cargo clippy --workspace fails on crates/prefill-router (chunks_exact), pre-existing and untouched here — reproduces on origin/main alone.

Summary by CodeRabbit

  • Bug Fixes

    • Request logs now omit session and correlation IDs when they are unavailable, instead of displaying empty values.
    • Logging consistently preserves the distinction between missing and empty identifiers for both completed and cancelled requests.
  • Documentation

    • Added an unreleased changelog entry describing the updated request-log behavior.

RequestLogContext::emit and emit_cancelled rendered session_id and
correlation_id with .unwrap_or(""), collapsing None and Some("") onto the
same session_id= output. That is a lossy projection: an operator reading
the request log cannot tell a request that sent no session from one that
sent a blank session.

Drop .unwrap_or("") at both sites. tracing-core's impl<T: Value> Value for
Option<T> skips None, so an absent id omits the field entirely while
Some("x") still renders session_id=x byte-identically to before.

requested_model, selected_model and error keep unwrap_or("") on purpose:
emit_cancelled hardcodes selected_model = "", so they mean "absent implies
empty" by design.

Widen the test subscriber to capture event fields as well as the message,
and add a table test over the three id shapes (absent, empty, present).
The absent row failed before the fix with left: Some(""), right: None.

Refs NVIDIA-NeMo#301

Signed-off-by: ChethanUK <chethanuk@outlook.com>
@chethanuk
chethanuk requested a review from a team as a code owner September 5, 2026 05:25
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e415330f-df39-46cb-8e07-00afcc182984

📥 Commits

Reviewing files that changed from the base of the PR and between 9a743e8 and f27a05d.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • crates/switchyard-server/src/lib.rs

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


Walkthrough

Request logging now preserves absent session and correlation IDs as missing fields. Completed and cancelled request tests capture all tracing fields and verify absent, empty, and populated identifier values. The changelog documents the fix.

Changes

Request logging

Layer / File(s) Summary
Optional identifier logging
crates/switchyard-server/src/lib.rs
Completed and cancelled request events pass optional session and correlation IDs to tracing without converting absent values to empty strings.
Event capture and coverage
crates/switchyard-server/src/lib.rs, CHANGELOG.md
Test event capture retains all fields. Tests verify absent, empty, and populated identifiers for completed and cancelled requests. The changelog records the fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to f27a0

Request logs now omit absent session and correlation IDs while retaining explicitly empty and populated values, improving diagnostic clarity without an identified current-head merge risk.

Poem

A rabbit logs fields in the moonlit night
Missing IDs vanish, as they should, from sight
Empty IDs remain, clear and true
Completed and cancelled logs do too
Tracing hops softly through the queue
“Clean fields!” sings the rabbit crew

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 1 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: absent request-log IDs are omitted instead of rendered as empty values.
Linked Issues check ✅ Passed The PR satisfies the logging objective in issue [#301] by omitting absent session and correlation ID fields while preserving explicitly empty values. The separate affinity-routing objectives are expli…
Out of Scope Changes check ✅ Passed The changelog update and expanded tests directly support the request-logging change. No unrelated code changes are identified.
Full details: Docstring Coverage

Explanation

Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 1 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI

Comment @coderabbitai help to get the list of available commands.

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.

Session affinity keys on an empty session id, and is silent when it cannot key at all

1 participant