{"record":{"id":"694ca3ac3bf1833b","repo":"leptos-rs/leptos","slug":"encoding-and-input-should-not-both-be-specifie","errorCode":null,"errorMessage":"`encoding` and `input` should not both be specified","messagePattern":"`encoding` and `input` should not both be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server_fn_macro/src/lib.rs","lineNumber":1113,"sourceCode":"                    } else if key == \"encoding\" {\n                        if encoding.is_some() {\n                            return Err(syn::Error::new(\n                                key.span(),\n                                \"keyword argument repeated: `encoding`\",\n                            ));\n                        }\n                        encoding = Some(stream.parse()?);\n                    } else if key == \"endpoint\" {\n                        if fn_path.is_some() {\n                            return Err(syn::Error::new(\n                                key.span(),\n                                \"keyword argument repeated: `endpoint`\",\n                            ));\n                        }\n                        fn_path = Some(stream.parse()?);\n                    } else if key == \"input\" {\n                        if encoding.is_some() {\n                            return Err(syn::Error::new(\n                                key.span(),\n                                \"`encoding` and `input` should not both be \\\n                                 specified\",\n                            ));\n                        } else if input.is_some() {\n                            return Err(syn::Error::new(\n                                key.span(),\n                                \"keyword argument repeated: `input`\",\n                            ));\n                        }\n                        input = Some(stream.parse()?);\n                    } else if key == \"input_derive\" {\n                        if input_derive.is_some() {\n                            return Err(syn::Error::new(\n                                key.span(),\n                                \"keyword argument repeated: `input_derive`\",\n                            ));\n                        }","sourceCodeStart":1095,"sourceCodeEnd":1131,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/server_fn_macro/src/lib.rs#L1095-L1131","documentation":"The #[server] macro rejects specifying both `encoding` and `input` because they configure the same thing (how the request body is deserialized) through overlapping mechanisms: `encoding` picks a built-in encoding, while `input` gives a fully custom input type. Allowing both would be ambiguous, so the parser errors at compile time.","triggerScenarios":"Writing #[server(encoding = \"...\", input = ...)] in the same attribute, e.g. mixing a legacy `encoding` arg with a newer `input` custom-type arg after a migration.","commonSituations":"Migrating from the older encoding API to custom input/output types and leaving the old `encoding` key in place; cargo expansions after upgrading server_fn versions; examples from docs that mix both styles.","solutions":["Remove the `encoding = ...` argument and keep `input = ...` for a custom input type.","Alternatively remove `input` and keep `encoding` to use a built-in encoding.","Note the companion check: `output` is likewise mutually exclusive with `encoding`."],"exampleFix":"// before\n#[server(encoding = \"Json\", input = MyInput)]\nasync fn save(data: MyInput) -> Result<(), ServerFnError> { todo!() }\n\n// after\n#[server(input = MyInput)]\nasync fn save(data: MyInput) -> Result<(), ServerFnError> { todo!() }","handlingStrategy":"validation","validationCode":"// Reject attributes mixing `encoding` with `input`/`output`:\n// grep -rnE '#\\[server\\([^)\\n]*encoding[^)\\n]*(input|output)\\s*=' src/ && exit 1 || exit 0","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember the rule: `encoding` XOR (`input` and/or `output`).","When migrating to custom types, delete the `encoding` key in the same change.","Check library upgrade notes before porting old attribute signatures.","Let cargo check fail loudly; never suppress macro errors with #[allow]."],"tags":["rust","proc-macro","compile-time","server-fn","mutually-exclusive-args"],"backgroundTag":"duplicate-macro-attribute-argument","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}