Skip to content

Commit d8b48c7

Browse files
jmoseleyCopilot
andcommitted
[Rust] Keep session IDs out of prepared-session test diagnostics
Two polling helpers formatted session identifiers into their failure messages: `await_no_registrations` rendered the router's registered ID list with `{:?}`, and `await_registered` interpolated the awaited ID. A downstream consumer that vendors this crate has CodeQL rules flagging identifiers reaching formatted output, so both were reported there even though the SDK's own analysis was clean. Report an outstanding-registration count and a static expectation message instead. Both helpers keep their exact predicates and deadline behavior: `await_no_registrations` still returns only when the router holds zero registrations, and `await_registered` still blocks on the exact ID it was given, so no assertion is weakened. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0f9d5ac7-9999-4f37-82b3-a5533bfbc1f6
1 parent de2ef25 commit d8b48c7

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

rust/tests/prepared_session_test.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,19 @@ fn expect_error<T>(result: Result<T, github_copilot_sdk::Error>) -> github_copil
186186
}
187187

188188
/// Poll (bounded) until the client's router has no registered sessions.
189+
///
190+
/// Diagnostics report how many registrations are outstanding rather than
191+
/// which ones: session IDs are not written to test output.
189192
async fn await_no_registrations(client: &Client) {
190193
let deadline = tokio::time::Instant::now() + TIMEOUT;
191-
while !client.registered_session_ids_for_test().is_empty() {
194+
loop {
195+
let outstanding = client.registered_session_ids_for_test().len();
196+
if outstanding == 0 {
197+
return;
198+
}
192199
assert!(
193200
tokio::time::Instant::now() < deadline,
194-
"session registration was never cleaned up: {:?}",
195-
client.registered_session_ids_for_test()
201+
"{outstanding} session registration(s) were never cleaned up"
196202
);
197203
tokio::task::yield_now().await;
198204
}
@@ -1043,6 +1049,9 @@ async fn cancelled_deferred_create_leaves_no_registration() {
10431049
}
10441050

10451051
/// Poll (bounded) until `session_id` shows up on the client's router.
1052+
///
1053+
/// The failure message names the expectation, not the ID: session IDs are
1054+
/// not written to test output.
10461055
async fn await_registered(client: &Client, session_id: &str) {
10471056
let deadline = tokio::time::Instant::now() + TIMEOUT;
10481057
while !client
@@ -1052,7 +1061,7 @@ async fn await_registered(client: &Client, session_id: &str) {
10521061
{
10531062
assert!(
10541063
tokio::time::Instant::now() < deadline,
1055-
"inline callback never registered {session_id}"
1064+
"inline callback never registered the expected session"
10561065
);
10571066
tokio::task::yield_now().await;
10581067
}

0 commit comments

Comments
 (0)