{"record":{"id":"460221534d68b78e","repo":"rust-lang/rust-analyzer","slug":"serialized-runnable","errorCode":null,"errorMessage":"serialized runnable","messagePattern":"serialized runnable","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/rust-analyzer/src/lsp/ext.rs","lineNumber":1005,"sourceCode":"                    \"--lib\".into(),\n                ],\n                executable_args: vec![\"my_test\".into(), \"--exact\".into()],\n            }),\n        };\n        let expected = json!({\n            \"label\": \"cargo test -p my-crate\",\n            \"kind\": \"cargo\",\n            \"args\": {\n                \"environment\": {\"RUSTC_TOOLCHAIN\": \"/toolchain\"},\n                \"cwd\": \"/project\",\n                \"overrideCargo\": null,\n                \"workspaceRoot\": \"/project\",\n                \"cargoArgs\": [\"test\", \"--package\", \"my-crate\", \"--lib\"],\n                \"executableArgs\": [\"my_test\", \"--exact\"],\n            }\n        });\n\n        let serialized = serde_json::to_value(&runnable).expect(\"serialized runnable\");\n        assert_eq!(serialized, expected);\n\n        let deserialized: Runnable =\n            serde_json::from_value(expected).expect(\"cargo runnable should deserialize\");\n        let RunnableArgs::Cargo(cargo) = &deserialized.args else {\n            panic!(\"expected Cargo variant, got {:?}\", deserialized.args);\n        };\n        assert_eq!(cargo.cargo_args, vec![\"test\", \"--package\", \"my-crate\", \"--lib\"]);\n        assert_eq!(cargo.executable_args, vec![\"my_test\", \"--exact\"]);\n    }\n\n    #[test]\n    fn shell_runnable_round_trips() {\n        let runnable = Runnable {\n            label: \"nextest test_one\".to_owned(),\n            location: None,\n            args: RunnableArgs::Shell(ShellRunnableArgs {\n                environment: [(\"RUSTC_TOOLCHAIN\".to_owned(), \"/toolchain\".to_owned())]","sourceCodeStart":987,"sourceCodeEnd":1023,"githubUrl":"https://github.com/rust-lang/rust-analyzer/blob/e8f7e90aa3e7b26aa9a000200f606c1078da99ec/crates/rust-analyzer/src/lsp/ext.rs#L987-L1023","documentation":"A unit test asserts that the Runnable struct serializes to JSON without failing. serde_json::to_value returns Err only if a map key is not a string or serialization is otherwise impossible; the expect turns that into a panic labeled \"serialized runnable\". Failure indicates the Runnable/RunnableArgs serde derive or a manual Serialize impl is broken.","triggerScenarios":"Modifying the Runnable, RunnableArgs (Cargo/Shell), or related lsp_ext types so serde_json::to_value fails — e.g. a non-string map key or a Serialize impl returning an error — then running cargo test -p rust-analyzer in crates/rust-analyzer/src/lsp/ext.rs.","commonSituations":"Contributors changing the rust-analyzer LSP extension API (runnable payload schema), switching serde attributes (untagged/adjacent tagging), or adding types that cannot serialize to JSON.","solutions":["Run the failing test with RUST_BACKTRACE=1 to locate which field's Serialize impl errors.","Fix the Serialize implementation/serde attributes on Runnable or its args so to_value cannot fail (all map keys must be strings).","Regenerate/adjust the expected JSON in the test only after confirming the new wire format is intended.","If the extension protocol intentionally changed, update the client extension's expected payload shape too."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// in the test, surface the underlying serde error instead of an opaque panic\nlet serialized = serde_json::to_value(&runnable)\n    .unwrap_or_else(|e| panic!(\"runnable failed to serialize: {e}\"));","typeGuard":"fn serializable<T: serde::Serialize>(v: &T) -> bool {\n    serde_json::to_value(v).is_ok()\n}","tryCatchPattern":null,"preventionTips":["Keep all map keys in serde payloads as String.","Prefer derived Serialize over manual impls for LSP extension types.","Run cargo test -p rust-analyzer after touching lsp_ext types.","Avoid serde attributes (like untagged) that complicate serialization guarantees."],"tags":["tests","serde","serialization","lsp-ext"],"backgroundTag":"serde-serialization-panic","analyzedSha":"e8f7e90aa3e7b26aa9a000200f606c1078da99ec","analyzedAt":"2026-09-03T21:08:06.959Z","contentChangedAt":"2026-09-03T21:08:06.959Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}