Hmbown/CodeWhale · warning
serialize rotated fixture
Error message
serialize rotated fixture
What it means
A panic from `serde_json::to_string(...).expect("serialize rotated fixture")` in the rotation branch of the credential-snapshot test. After construction, the test rewrites auth.json with account-B credentials to prove the client keeps its original snapshot; serializing that replacement JSON failed. As with the initial serialize, an in-memory json! literal failing to serialize signals allocation failure or serde_json version inconsistency, not bad data.
Solutions
- Re-run the test and check CI logs for OOM kills.
- Ensure one serde_json version via cargo tree -d / cargo update -p serde_json.
- Compare with the earlier to_vec call in the same test — if only this one fails, suspect a local edit to the literal.
- Raise memory limits if running under tight container constraints.
Defensive patterns
Strategy: try-catch
Try / catch
let rotated = serde_json::to_string(&serde_json::json!({...}))
.unwrap_or_else(|e| panic!("serialize rotated fixture: {e}")); Prevention
- Keep serde/serde_json versions consistent across the workspace.
- Check CI for OOM when serialization of literal json! values fails.
- Mirror the working to_vec pattern earlier in the test when adding rotation steps.
When it happens
Trigger: `serde_json::to_string(&serde_json::json!({"tokens": {"access_token": ..., "account_id": "account-b"}})).expect("serialize rotated fixture")` returns Err during the rotation step of the test.
Common situations: OOM on constrained CI runners; inconsistent serde/serde_json versions after a dependency update.
Understand the failure class
Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.
Related errors
- serialize fixture
- ApplyPatchPreflight should serialize
- bundled model catalog must parse
- canonical temp root
- Codex client
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/41b6b7445b05e0dc.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/client.rs:8301
}),
..Config::default()
};
crate::external_credentials::reset_side_effect_trap();
let client = CodewhaleClient::new(&config).expect("Codex client");
assert_eq!(client.api_key, token_a);
assert_eq!(client.codex_account_id.as_deref(), Some("account-a"));
assert_eq!(
crate::external_credentials::side_effect_trap_counts(),
(1, 1),
"bearer and account id must come from one secure open/read"
);
// An owner rotation after construction cannot splice account B into
// the already-resolved bearer snapshot.
std::fs::write(
&path,
serde_json::to_string(&serde_json::json!({"tokens": {"access_token": crate::test_support::future_test_jwt("b"), "account_id": "account-b"}})).expect("serialize rotated fixture"),
)
.expect("rotate fixture");
assert_eq!(client.api_key, token_a);
assert_eq!(client.codex_account_id.as_deref(), Some("account-a"));
}
fn client_with_config_secret_sentinels() -> CodewhaleClient {
let _ = rustls::crypto::ring::default_provider().install_default();
CodewhaleClient::new(&Config {
provider: Some("zai".to_string()),
api_key: Some(CONFIG_SECRET_SENTINELS[0].to_string()),
providers: Some(ProvidersConfig {
arcee: ProviderConfig {
api_key: Some(CONFIG_SECRET_SENTINELS[1].to_string()),
..ProviderConfig::default()
},
moonshot: ProviderConfig {
api_key: Some(CONFIG_SECRET_SENTINELS[2].to_string()),View on GitHub (pinned to 73e0f67d83)