Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
WalkthroughA new README.md file is added to the acp-nats-stdio crate, documenting the crate's purpose, features, configuration options, and usage instructions. The documentation covers NATS and ACP configuration, authentication, logging, OpenTelemetry observability, and includes a data flow diagram. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ad93c4c to
5f2ba1e
Compare
PR SummaryLow Risk Overview Written by Cursor Bugbot for commit 9ae73bd. This will update automatically on new commits. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| Err(error) => return Err(invalid_session_id_error(bridge, error)), | ||
| let session_id = match bridge.validate_session(&args.session_id) { | ||
| Ok(sid) => sid, | ||
| Err(e) => return Err(invalid_session_id_error(bridge, e)), |
There was a problem hiding this comment.
Prompt validation double-wraps error message and metrics
High Severity
The prompt handler passes the Error returned by validate_session into invalid_session_id_error, which wraps it again with format!("Invalid session ID: {}", error). Since validate_session already formats the message as "Invalid session ID: ...", the final error message becomes "Invalid session ID: Invalid session ID: ...". Additionally, both validate_session (recording "session.validate") and invalid_session_id_error (recording "prompt") call record_error, double-counting the same validation failure in metrics.
Additional Locations (2)
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| Err(error) => return Err(invalid_session_id_error(bridge, error)), | ||
| let session_id = match bridge.validate_session(&args.session_id) { | ||
| Ok(sid) => sid, | ||
| Err(e) => return Err(invalid_session_id_error(bridge, e)), |
There was a problem hiding this comment.
Double-wrapped "Invalid session ID" error message in prompt
Medium Severity
validate_session already returns an Error with message "Invalid session ID: {reason}" and records a "session.validate" error metric. The prompt handler then passes this Error (which implements Display) into invalid_session_id_error, which wraps it again as format!("Invalid session ID: {}", error). The resulting error message will be "Invalid session ID: Invalid session ID: ..." — a double-wrap. The error metric is also double-counted. Other callers like cancel, load_session, and set_session_mode correctly use ? to propagate the error directly from validate_session.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
Cancel handler loses request metric on validation failure
Medium Severity
The cancel handler uses ? on bridge.validate_session(...), which causes an early return before record_request at line 59 is reached. The old code explicitly called bridge.metrics.record_request("cancel", ..., false) inside the map_err closure before returning the validation error. This regression means failed cancel requests due to invalid session IDs are no longer tracked in the acp.requests metric, breaking monitoring/dashboards that rely on it.
|
|
||
| pub(crate) fn validate_session(&self, session_id: &SessionId) -> Result<AcpSessionId> { | ||
| AcpSessionId::try_from(session_id).map_err(|e| { | ||
| self.metrics.record_error("session.validate", "invalid_session_id"); |
There was a problem hiding this comment.
Metric operation key changed from underscore to dot
Low Severity
The validate_session method records the error metric with operation "session.validate" (dot-separated), whereas the old inline validation in load_session.rs and set_session_mode.rs used "session_validate" (underscore-separated). This silent naming change may break existing dashboards, alerts, or queries that filter on the old "session_validate" operation key.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 4 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
Cancel handler loses request metric on validation failure
Medium Severity
The old cancel::handle recorded record_request("cancel", ..., false) inside the map_err closure before the ? early return on session ID validation failure. The new code calls bridge.validate_session(&args.session_id)?, which returns early on failure, skipping the record_request call at line 59–62. This means the acp.requests counter no longer increments for cancel requests that fail validation — a metrics regression.
|
|
||
| let session_id = match AcpSessionId::try_from(&args.session_id) { | ||
| Ok(session_id) => session_id, | ||
| Err(error) => return Err(invalid_session_id_error(bridge, error)), |
There was a problem hiding this comment.
Prompt records duplicate error metrics on validation failure
Medium Severity
When a prompt request has an invalid session ID, validate_session records an error metric with operation "session.validate", then invalid_session_id_error records a second error metric with operation "prompt". The old code only called invalid_session_id_error (via AcpSessionId::try_from which doesn't record metrics), so only one error metric was emitted. This double counting inflates acp.errors.
| - `NATS_TOKEN` - NATS token (optional) | ||
| - `ACP_PREFIX` - Custom subject prefix for multi-tenancy (default: `acp`) | ||
| - `ACP_LOG_DIR` - Directory for file-based logging (optional) | ||
| - `OTEL_EXPORTER_OTLP_ENDPOINT` - OpenTelemetry collector endpoint (optional) |
There was a problem hiding this comment.
New environment variables need verification across environments
Low Severity
Several new environment variables are introduced: NATS_URL, NATS_USER, NATS_PASSWORD, NATS_TOKEN, ACP_PREFIX, ACP_LOG_DIR, OTEL_EXPORTER_OTLP_ENDPOINT, ACP_OPERATION_TIMEOUT_SECS, ACP_PROMPT_TIMEOUT_SECS, and ACP_NATS_CONNECT_TIMEOUT_SECS. Per team rules, each new environment variable needs to be verified as created in every single deployment environment.
Triggered by team rule: Check For environment Variables
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| }) | ||
| } |
There was a problem hiding this comment.
Validate_session changes error operation label silently
Low Severity
The centralized validate_session records errors with operation "session.validate", but the old per-handler code used handler-specific labels like "cancel" or "session_validate". This silently changes the metric label, which could break existing dashboards or alerts that filter on the old operation names.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
|
|
||
| let session_id = match AcpSessionId::try_from(&args.session_id) { | ||
| Ok(session_id) => session_id, | ||
| Err(error) => return Err(invalid_session_id_error(bridge, error)), |
There was a problem hiding this comment.
Double-wrapped error message in prompt validation path
Medium Severity
validate_session already wraps the error with "Invalid session ID: {e}" and records record_error("session.validate", ...). Then invalid_session_id_error receives that Error (which implements Display) and wraps it again with format!("Invalid session ID: {}", error), producing a double-wrapped message like "Invalid session ID: Invalid session ID: ...". It also records a second error metric (record_error("prompt", "invalid_session_id")), causing double-counting.
Additional Locations (1)
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
Cancel handler skips request metric on validation failure
Medium Severity
The ? operator on validate_session causes early return when validation fails, skipping record_request("cancel", ...) at line 59. The old cancel handler explicitly recorded the request metric inside the map_err closure before returning. Now validation failures are invisible to the acp.requests counter for the cancel method.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
Cancel handler loses request metric on validation failure
Medium Severity
The validate_session call with ? causes an early return when session validation fails, skipping the record_request("cancel", ...) at the bottom of the function. The old code explicitly called bridge.metrics.record_request("cancel", ..., false) inside the map_err closure before propagating the error. Now, failed cancel requests due to invalid session IDs are no longer counted in the acp.requests metric, breaking request-counting accuracy.
| - `NATS_TOKEN` - NATS token (optional) | ||
| - `ACP_PREFIX` - Custom subject prefix for multi-tenancy (default: `acp`) | ||
| - `ACP_LOG_DIR` - Directory for file-based logging (optional) | ||
| - `OTEL_EXPORTER_OTLP_ENDPOINT` - OpenTelemetry collector endpoint (optional) |
There was a problem hiding this comment.
New environment variables need deployment verification
Low Severity
This PR introduces several new environment variables: NATS_URL, NATS_USER, NATS_PASSWORD, NATS_TOKEN, ACP_PREFIX, ACP_LOG_DIR, OTEL_EXPORTER_OTLP_ENDPOINT, ACP_OPERATION_TIMEOUT_SECS, ACP_PROMPT_TIMEOUT_SECS, and ACP_NATS_CONNECT_TIMEOUT_SECS. Per team rules, the developer needs to verify that all new environment variables are created in every single environment.
Triggered by team rule: Check For environment Variables
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| }) | ||
| } |
There was a problem hiding this comment.
Metric operation label silently changed from old names
Low Severity
The centralized validate_session method records errors with operation="session.validate", but the old inline validation in cancel.rs used operation="cancel" and in set_session_mode.rs/load_session.rs used operation="session_validate". Any existing dashboards or alerts keyed on the old operation labels will silently stop matching these validation errors.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
Cancel validation failure skips request metric recording
Medium Severity
The old cancel handler explicitly called record_request("cancel", ..., false) inside the map_err closure when session validation failed. The new code uses bridge.validate_session(&args.session_id)? which early-returns before the record_request call at line 59–63. This means cancel requests that fail validation are no longer counted in the acp.requests metric, causing an observability regression.
| - `NATS_TOKEN` - NATS token (optional) | ||
| - `ACP_PREFIX` - Custom subject prefix for multi-tenancy (default: `acp`) | ||
| - `ACP_LOG_DIR` - Directory for file-based logging (optional) | ||
| - `OTEL_EXPORTER_OTLP_ENDPOINT` - OpenTelemetry collector endpoint (optional) |
There was a problem hiding this comment.
New environment variables may not exist in all environments
Low Severity
This PR introduces several new environment variables: NATS_URL, NATS_USER, NATS_PASSWORD, NATS_TOKEN, ACP_PREFIX, ACP_LOG_DIR, OTEL_EXPORTER_OTLP_ENDPOINT, ACP_OPERATION_TIMEOUT_SECS, ACP_PROMPT_TIMEOUT_SECS, and ACP_NATS_CONNECT_TIMEOUT_SECS. Per the project rules, the developer needs to verify that each new environment variable is created in every single deployment environment.
Triggered by team rule: Check For environment Variables
| map.remove(session_id); | ||
| None | ||
| } | ||
| } |
There was a problem hiding this comment.
Unconditional removal in take_if_cancelled defeats repeated cancel checks
Medium Severity
take_if_cancelled removes the entry from the map in both the valid and invalid (expired/missing) branches. In prompt.rs, this method is called twice — once before register_waiter and once after. The first call consumes and removes the cancellation entry, so the second call can never observe a cancellation that occurred before the first call. If the intent is a two-phase check, only a successful match (valid cancel) should remove the entry.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| let cleanup_due_count = self.cleanup_counter.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| if cleanup_due_count % CLEANUP_EVERY == 0 { | ||
| map.retain(|_, ts| clock.elapsed(*ts) < CANCELLED_SESSION_TTL); | ||
| } |
There was a problem hiding this comment.
Cleanup triggers on first call due to counter starting at zero
Low Severity
mark_cancelled uses fetch_add which returns the previous value. On the very first call the counter is 0, so 0 % CLEANUP_EVERY == 0 is true and a full retain scan of the map runs immediately. This means every 16th cancellation triggers cleanup starting from the first one, rather than after 16 cancellations. While not catastrophic, this is an off-by-one that causes an unnecessary map scan on the very first insert when the map is trivially small, and shifts every subsequent cleanup window by one.
| map.remove(session_id); | ||
| None | ||
| } | ||
| } |
There was a problem hiding this comment.
Expired cancelled entries silently removed without returning cancelled
Medium Severity
take_if_cancelled unconditionally removes the map entry in both the valid and expired branches. When an entry exists but has expired (older than CANCELLED_SESSION_TTL), it is silently removed and None is returned, meaning the prompt proceeds as if no cancellation occurred. This creates a race window: if a cancel arrives but the prompt comes more than 5 minutes later, the cancellation is silently lost and the entry is cleaned up, so a second prompt check also won't see it. The else branch that removes expired entries appears unintentional — expired entries would be cleaned up by mark_cancelled anyway.
|
|
||
| pub(crate) fn validate_session(&self, session_id: &SessionId) -> Result<AcpSessionId> { | ||
| AcpSessionId::try_from(session_id).map_err(|e| { | ||
| self.metrics.record_error("session.validate", "invalid_session_id"); |
There was a problem hiding this comment.
Metric operation name changed from session_validate to session.validate
Medium Severity
The centralized validate_session method records errors with operation name "session.validate" (with a dot), but the previous per-handler code used "session_validate" (with an underscore) in load_session and set_session_mode, and "cancel" in the cancel handler. This silently changes the metric label for dashboards and alerts that rely on the old "session_validate" operation name, and the cancel handler now records validation errors under "session.validate" instead of "cancel", losing the per-operation granularity.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
|
|
||
| let session_id = match AcpSessionId::try_from(&args.session_id) { | ||
| Ok(session_id) => session_id, | ||
| Err(error) => return Err(invalid_session_id_error(bridge, error)), |
There was a problem hiding this comment.
Double-wrapped "Invalid session ID" error message in prompt
Medium Severity
validate_session already returns an Error with message "Invalid session ID: {reason}". The prompt handler then passes this Error to invalid_session_id_error, which wraps it again with format!("Invalid session ID: {}", error). The resulting user-facing message will read "Invalid session ID: Invalid session ID: {reason}". Other handlers (cancel, load_session, set_session_mode) correctly propagate the error from validate_session directly via ?, avoiding the double wrapping.
Additional Locations (1)
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| Err(error) => return Err(invalid_session_id_error(bridge, error)), | ||
| let session_id = match bridge.validate_session(&args.session_id) { | ||
| Ok(sid) => sid, | ||
| Err(e) => return Err(invalid_session_id_error(bridge, e)), |
There was a problem hiding this comment.
Double-wrapped error message in prompt validation failure
Medium Severity
When validate_session fails in the prompt handler, the error gets double-wrapped. validate_session already creates an Error with message "Invalid session ID: {e}". Then invalid_session_id_error wraps that again as "Invalid session ID: {error}", producing "Invalid session ID: Invalid session ID: ...". The old code passed the raw validation error to invalid_session_id_error, not a pre-formatted Error. This also double-records error metrics — once as ("session.validate", "invalid_session_id") inside validate_session and again as ("prompt", "invalid_session_id") inside invalid_session_id_error.
Additional Locations (1)
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
Cancel handler skips request metric on validation failure
Low Severity
The cancel handler now uses bridge.validate_session(&args.session_id)? which early-returns before reaching the record_request("cancel", ...) call at the end. The old code explicitly called record_request("cancel", ..., false) inside the validation error path before propagating. This means cancelled-due-to-invalid-session requests are no longer counted in the acp.requests metric for the cancel method.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| Err(error) => return Err(invalid_session_id_error(bridge, error)), | ||
| let session_id = match bridge.validate_session(&args.session_id) { | ||
| Ok(sid) => sid, | ||
| Err(e) => return Err(invalid_session_id_error(bridge, e)), |
There was a problem hiding this comment.
Double-wrapped error message in prompt session validation
Medium Severity
validate_session already returns an Error with message "Invalid session ID: {e}". The prompt handler then passes this Error (which implements Display) into invalid_session_id_error, which wraps it again with format!("Invalid session ID: {}", error). The resulting error message becomes "Invalid session ID: Invalid session ID: session_id contains invalid character: '.'". Additionally, two separate error metrics are recorded for a single failure: one from validate_session ("session.validate") and one from invalid_session_id_error ("prompt").
Additional Locations (2)
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
Cancel validation failure skips request metric recording
Low Severity
When validate_session fails, the ? operator causes an early return before record_request on line 59. Previously, the cancel handler explicitly called record_request("cancel", ..., false) inside the validation error path. Now, cancel requests with invalid session IDs are silently missing from the acp.requests metric, reducing observability for failed cancel attempts.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| Err(error) => return Err(invalid_session_id_error(bridge, error)), | ||
| let session_id = match bridge.validate_session(&args.session_id) { | ||
| Ok(sid) => sid, | ||
| Err(e) => return Err(invalid_session_id_error(bridge, e)), |
There was a problem hiding this comment.
Double-wrapped error message in prompt validation path
Medium Severity
validate_session already formats errors as "Invalid session ID: {e}" and returns an Error. When that Error (implementing Display) is passed to invalid_session_id_error, it wraps it again with format!("Invalid session ID: {}", error), producing a doubled message like "Invalid session ID: Invalid session ID: ...". Additionally, two error metrics are recorded: one by validate_session ("session.validate") and one by invalid_session_id_error ("prompt").
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
Cancel handler loses request metric on validation failure
Low Severity
The ? operator on validate_session causes an early return, skipping the record_request("cancel", ...) call at the bottom of the function. The old code explicitly called record_request("cancel", ..., false) in the validation error path. Now, validation failures in cancel are invisible to the acp.requests metric, breaking observability for this error path.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
Cancel skips request metric on validation failure
Medium Severity
The old cancel handler explicitly recorded record_request("cancel", ..., false) inside the map_err closure when session validation failed. The refactored code uses bridge.validate_session(&args.session_id)? which returns early via ?, skipping the bridge.metrics.record_request("cancel", ...) call at the bottom of the function. This means invalid-session cancel attempts are no longer counted in the acp.requests metric, causing a metric reporting regression for this error path.
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| let session_id = bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
load_session/set_session_mode skip request metric on validation failure
Low Severity
Both load_session and set_session_mode use bridge.validate_session(&args.session_id)? which returns early via ?, skipping the record_request metric call at the bottom of each function. When validation fails, no request metric is emitted at all — only the error metric from validate_session. This is consistent with their old behavior (the old code also skipped record_request on validation failure), but it's worth noting this gap remains unfixed after the refactoring that was clearly intended to consolidate validation.
Additional Locations (1)
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
Cancel missing request metric on validation failure
Medium Severity
The old cancel handler explicitly recorded record_request("cancel", ..., false) inside the map_err closure when session validation failed, ensuring the request metric was always emitted. The new code uses bridge.validate_session(&args.session_id)?, which returns early via ? on failure — skipping record_request at line 59–63. This means cancel requests with invalid session IDs no longer appear in the acp.requests metric, breaking observability dashboards that track cancel request volume and error rates.
| Err(error) => return Err(invalid_session_id_error(bridge, error)), | ||
| let session_id = match bridge.validate_session(&args.session_id) { | ||
| Ok(sid) => sid, | ||
| Err(e) => return Err(invalid_session_id_error(bridge, e)), |
There was a problem hiding this comment.
Prompt handler double-records error metrics on validation failure
Low Severity
When session validation fails, validate_session records record_error("session.validate", "invalid_session_id"), and then invalid_session_id_error records a second record_error("prompt", "invalid_session_id"). The old code only recorded one error metric per validation failure. This inflates error counts and may confuse alerting rules tracking error rates.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| Err(error) => return Err(invalid_session_id_error(bridge, error)), | ||
| let session_id = match bridge.validate_session(&args.session_id) { | ||
| Ok(sid) => sid, | ||
| Err(e) => return Err(invalid_session_id_error(bridge, e)), |
There was a problem hiding this comment.
Double error metric recording for invalid session in prompt
Medium Severity
When the prompt handler receives an invalid session ID, validate_session records record_error("session.validate", "invalid_session_id"), and then invalid_session_id_error also records record_error("prompt", "invalid_session_id"). This double-counts error metrics. The old code only recorded one error metric via invalid_session_id_error. The new shared validate_session helper unconditionally records its own metric before the caller-specific helper adds another.
Additional Locations (1)
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
Cancel handler loses request metric on validation failure
Low Severity
The cancel handler now uses bridge.validate_session(&args.session_id)? which returns early on failure before record_request at the bottom of the function is reached. The old cancel code explicitly called record_request("cancel", ..., false) inside the validation error path. This means invalid session ID cancels no longer increment the acp.requests counter, a regression in metrics completeness that the old tests verified.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 4 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
Validation failure skips request metric recording in cancel
Medium Severity
When validate_session fails, the ? operator causes an early return on line 28, completely skipping the record_request("cancel", ...) call at lines 59-63. The old code explicitly recorded the request metric (with success=false) before returning the validation error. Now, cancel requests with invalid session IDs are invisible in acp.requests metrics.
|
|
||
| pub(crate) fn validate_session(&self, session_id: &SessionId) -> Result<AcpSessionId> { | ||
| AcpSessionId::try_from(session_id).map_err(|e| { | ||
| self.metrics.record_error("session.validate", "invalid_session_id"); |
There was a problem hiding this comment.
Metric operation name changed from session_validate to session.validate
Medium Severity
The centralized validate_session method records the error metric with operation "session.validate" (dot separator), but the old per-handler code used "session_validate" (underscore). This changes the metric label emitted for validation errors, potentially breaking existing dashboards, alerts, or queries that filter on the old operation name.
| format!("Invalid session ID: {}", e), | ||
| ) | ||
| })?; | ||
| let session_id = bridge.validate_session(&args.session_id)?; |
There was a problem hiding this comment.
Validation failure skips request metrics in load_session and set_session_mode
Medium Severity
Same issue as cancel: bridge.validate_session(&args.session_id)? early-returns before record_request is called. Both load_session and set_session_mode handlers now silently drop request metrics when session validation fails, creating observability gaps compared to the previous behavior.
Additional Locations (1)
| SystemClock, | ||
| &meter, | ||
| config.clone(), | ||
| )); |
There was a problem hiding this comment.
Rc<Bridge> used but spawn_session_ready calls tokio::spawn
High Severity
In main.rs, Bridge is wrapped in Rc for the !Send LocalSet context, but spawn_session_ready (called from new_session and load_session handlers) uses tokio::spawn which requires Send. When new_session or load_session succeeds and calls spawn_session_ready, the tokio::spawn will attempt to schedule on the multi-threaded runtime while running inside a LocalSet, which will likely panic or behave unexpectedly.
Additional Locations (1)
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| Err(error) => return Err(invalid_session_id_error(bridge, error)), | ||
| let session_id = match bridge.validate_session(&args.session_id) { | ||
| Ok(sid) => sid, | ||
| Err(e) => return Err(invalid_session_id_error(bridge, e)), |
There was a problem hiding this comment.
Double-wrapped error message and duplicate metrics in prompt validation
Medium Severity
validate_session already wraps the error as "Invalid session ID: {e}" and records record_error("session.validate", ...). When the prompt handler passes that Error to invalid_session_id_error, it wraps it again producing "Invalid session ID: Invalid session ID: {original}" and records a second error metric record_error("prompt", "invalid_session_id"). Before this refactor, invalid_session_id_error received the raw SessionIdError, not the pre-wrapped Error. The other handlers (cancel, load_session, set_session_mode) correctly use validate_session with ? directly, avoiding this double-wrapping.
Additional Locations (2)
| const MAX_SESSION_ID_LENGTH: usize = 128; | ||
| #[allow(dead_code)] | ||
| const MAX_SESSIONED_SUBJECT_SUFFIX_LEN: usize = | ||
| ".client.ext.session.prompt_response".len(); |
There was a problem hiding this comment.
Subject suffix validation misses agent-side session subjects
Low Severity
MAX_SESSIONED_SUBJECT_SUFFIX_LEN is derived from client suffixes only, but session-scoped agent subjects (e.g. .agent.session.set_mode, .agent.ext.session.ready) also contribute to subject length. The max_sessioned_subject_suffix_len_covers_known_suffixes test only validates client suffixes, creating a false sense of completeness. If an agent suffix longer than 35 bytes is added in the future, validate_subject_capacity would silently under-count. While these are currently dead_code, the test's name and assertion message imply full coverage.
Additional Locations (1)
Code Coverage SummaryDetailsDiff against mainResults for commit: 9ae73bd Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>


Signed-off-by: Yordis Prieto yordis.prieto@gmail.com