{"record":{"id":"2d9ec3424905e41c","repo":"leptos-rs/leptos","slug":"encoding-and-output-should-not-both-be-specifi","errorCode":null,"errorMessage":"`encoding` and `output` should not both be specified","messagePattern":"`encoding` and `output` should not both be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server_fn_macro/src/lib.rs","lineNumber":1127,"sourceCode":"                        }\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                        }\n                        input_derive = Some(stream.parse()?);\n                    } else if key == \"output\" {\n                        if encoding.is_some() {\n                            return Err(syn::Error::new(\n                                key.span(),\n                                \"`encoding` and `output` should not both be \\\n                                 specified\",\n                            ));\n                        } else if output.is_some() {\n                            return Err(syn::Error::new(\n                                key.span(),\n                                \"keyword argument repeated: `output`\",\n                            ));\n                        }","sourceCodeStart":1109,"sourceCodeEnd":1145,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/server_fn_macro/src/lib.rs#L1109-L1145","documentation":"The #[server] macro parser errors when both `encoding` and `output` are specified. They configure the same concern — how the response body is serialized — via different mechanisms (built-in encoding vs. custom output type), so combining them is ambiguous and fails at compile time.","triggerScenarios":"Writing #[server(encoding = \"...\", output = ...)] in one attribute, typically after migrating from the encoding API to custom output types without removing `encoding`.","commonSituations":"Upgrading server_fn/leptos across versions where `output` was introduced; mixing doc examples; leaving both args after an LLM-assisted or manual refactor.","solutions":["Remove `encoding = ...` and keep `output = ...` for a custom output type.","Or remove `output` and keep `encoding` to use a built-in encoding.","Remember the same rule applies to `input`: it cannot coexist with `encoding`."],"exampleFix":"// before\n#[server(encoding = \"Json\", output = MyOutput)]\nasync fn load() -> Result<MyOutput, ServerFnError> { todo!() }\n\n// after\n#[server(output = MyOutput)]\nasync fn load() -> Result<MyOutput, ServerFnError> { todo!() }","handlingStrategy":"validation","validationCode":"// Reject attributes mixing `encoding` with `output`:\n// grep -rnE '#\\[server\\([^)\\n]*encoding[^)\\n]*output\\s*=' src/ && exit 1 || exit 0","typeGuard":null,"tryCatchPattern":null,"preventionTips":["`encoding` and `output` configure the same concern — never combine them.","Use `output` for custom response types; use `encoding` alone for built-ins.","Remove legacy `encoding` keys when adopting the input/output API.","Run cargo check before committing macro-heavy code."],"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"}