{"record":{"id":"8b775cfe59d2e6dd","repo":"leptos-rs/leptos","slug":"should-serialize-string","errorCode":null,"errorMessage":"should serialize string","messagePattern":"should serialize string","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"oco/src/lib.rs","lineNumber":733,"sourceCode":"    #[test]\n    fn cloned_inplace_borrowed_str_should_make_borrowed_str_and_remain_borrowed(\n    ) {\n        let mut s: Oco<str> = Oco::Borrowed(\"hello\");\n        assert!(s.clone_inplace().is_borrowed());\n        assert!(s.is_borrowed());\n    }\n\n    #[test]\n    fn cloned_inplace_counted_str_should_make_counted_str_and_remain_counted() {\n        let mut s: Oco<str> = Oco::Counted(Arc::from(\"hello\"));\n        assert!(s.clone_inplace().is_counted());\n        assert!(s.is_counted());\n    }\n\n    #[test]\n    fn serialization_works() {\n        let s = serde_json::to_string(&Oco::Borrowed(\"foo\"))\n            .expect(\"should serialize string\");\n        assert_eq!(s, \"\\\"foo\\\"\");\n    }\n\n    #[test]\n    fn deserialization_works() {\n        let s: Oco<str> = serde_json::from_str(\"\\\"bar\\\"\")\n            .expect(\"should deserialize from string\");\n        assert_eq!(s, Oco::from(String::from(\"bar\")));\n    }\n}\n","sourceCodeStart":715,"sourceCodeEnd":744,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/oco/src/lib.rs#L715-L744","documentation":"This is a test assertion inside the oco crate: serde_json::to_string(&Oco::Borrowed(\"foo\")) is expected to succeed, since Oco<'a, str> serializes as a plain string. The expect fires only if serialization returns an Err, which would indicate a broken Serialize impl for the Oco type rather than a user-facing condition.","triggerScenarios":"Only in the crate's own test suite (serialization_works): a regression in Oco's Serialize implementation, an incompatible serde_json version, or a feature-flag combination (e.g. serde feature off) that breaks serialization.","commonSituations":"Contributors bumping serde/serde_json versions, disabling default features, or modifying Oco's enum variants so the Serialize derive/impl no longer handles Borrowed correctly.","solutions":["Re-enable the `serde` feature of the oco crate so Serialize/Deserialize impls are compiled.","Fix or restore the Serialize impl for Oco so all variants (Borrowed, Counted, Owned) emit plain strings.","Check for serde/serde_json version incompatibilities introduced by Cargo.lock updates.","Run cargo test -p oco to confirm the fix."],"exampleFix":"// before: feature missing in Cargo.toml\noco = { path = \"../oco\", default-features = false }\n\n// after\noco = { path = \"../oco\", features = [\"serde\"] }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn is_oco_str_serializable(v: &Oco<'_, str>) -> bool {\n    serde_json::to_string(v).is_ok()\n}","tryCatchPattern":"match serde_json::to_string(&value) {\n    Ok(s) => s,\n    Err(e) => { log::error!(\"oco serialization failed: {e}\"); String::new() }\n}","preventionTips":["Keep the `serde` feature enabled for the oco crate.","Run cargo test -p oco after version bumps.","Keep all Oco variants covered by the Serialize impl."],"tags":["rust","serde","tests","oco"],"backgroundTag":"serde-serialization-failed","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}