{"record":{"id":"1d0c70a26622e22f","repo":"leptos-rs/leptos","slug":"should-deserialize-from-string","errorCode":null,"errorMessage":"should deserialize from string","messagePattern":"should deserialize from string","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"oco/src/lib.rs","lineNumber":740,"sourceCode":"\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":722,"sourceCodeEnd":744,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/oco/src/lib.rs#L722-L744","documentation":"Test assertion in the oco crate: deserializing the JSON string \"\\\"bar\\\"\" into Oco<'_, str> should succeed and yield Oco::from(String::from(\"bar\")). The expect panics if serde_json::from_str returns Err, signaling a broken Deserialize impl for Oco rather than a runtime condition users can trigger.","triggerScenarios":"Only in the crate's own test suite (deserialization_works): a regression in Oco's Deserialize implementation, missing serde feature, or serde_json version incompatibility.","commonSituations":"Feature-flag changes that drop the Deserialize impl, editing Oco variants (e.g. lifetime changes) so the visitor no longer accepts strings, or Cargo.lock drift pulling a broken serde combination.","solutions":["Enable the `serde` feature of the oco crate.","Restore/fix the Deserialize impl (and its visitor) so string input deserializes into Oco::Owned/Counted.","Pin compatible serde/serde_json versions and update Cargo.lock.","Run cargo test -p oco to verify."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn parses_as_oco(raw: &str) -> bool {\n    serde_json::from_str::<Oco<'_, str>>(raw).is_ok()\n}","tryCatchPattern":"match serde_json::from_str::<Oco<str>>(raw) {\n    Ok(v) => v,\n    Err(e) => { log::error!(\"oco deserialization failed: {e}\"); Oco::Borrowed(\"\") }\n}","preventionTips":["Enable the `serde` feature of the oco crate.","Keep the Deserialize visitor accepting plain JSON strings.","Run cargo test -p oco in CI."],"tags":["rust","serde","tests","oco"],"backgroundTag":"serde-deserialization-failed","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}