Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(app_state): assert the stored identity, not just its presence\n\nCodeRabbit review on #5950. `is_some()` did not prove the snapshot kept\n`empty-user-round`: the backend answers `{}`, and a snapshot that echoed that\nback as `Some({})` would have satisfied the assertion while having lost the\nuser. Now asserts the id.\n\nThe same review suggested also asserting `current_user_stale`. Checked it\nagainst the running code rather than assuming, and it is `false` here — so\nthat assertion would have failed. `current_user_stale` reports whether the\nbackend could be *reached*, and an empty 200 is the backend answering, not an\noutage; it is derived from the same failure record that drives the backoff,\nwhich this path clears. Treating it as stale would conflate an outage with an\naccount that has no profile, and would raise the flag while the backoff it\ncomes from is closed. The "cannot vouch for this data" signal is carried by\n`current_user_stale_seconds: None`, which is distinguishable from `Some(n)`.\n\nAsserted explicitly as `!current_user_stale` with that reasoning inline, so\nthe next reader does not have to re-derive it.\n

Shanu4437c9921d1d
diff --git a/tests/raw_coverage/app_state_credentials_raw_coverage_e2e.rs b/tests/raw_coverage/app_state_credentials_raw_coverage_e2e.rs
index 4e9e871aaa..a3b5143223 100644
--- a/tests/raw_coverage/app_state_credentials_raw_coverage_e2e.rs
+++ b/tests/raw_coverage/app_state_credentials_raw_coverage_e2e.rs
@@ -1557,10 +1557,22 @@ async fn an_empty_user_response_is_not_counted_as_a_refresh() {
.expect("snapshot with an empty backend user")
.value;
- // The stored identity is still what the app shows.
+ // The stored identity is still what the app shows. Asserted by id, not
+ // `is_some()`: the backend answered `{}`, and a snapshot that echoed that
+ // back as `Some({})` would satisfy `is_some()` while having lost the user.
+ assert_eq!(
+ snap.current_user.as_ref().and_then(|v| v.get("id")),
+ Some(&json!("empty-user-round")),
+ "an empty backend answer must leave the stored identity in place"
+ );
+ // NOT stale: `current_user_stale` reports whether the backend could be
+ // *reached*, and here it answered fine — it simply had no user. Marking an
+ // empty 200 as stale would conflate an outage with an account that has no
+ // profile, and would keep the flag raised while the backoff it is derived
+ // from is closed.
assert!(
- snap.current_user.is_some(),
- "an empty backend answer must leave the stored user in place"
+ !snap.current_user_stale,
+ "a backend that answered is not an outage, even when it answered empty"
);
// And its age is unknown rather than zero: nothing was refreshed, so there
// is no successful refresh to measure from.