{"record":{"id":"615410ae6d93c93d","repo":"pydantic/monty","slug":"toargs-does-not-yet-support-varkwargs-fields","errorCode":null,"errorMessage":"ToArgs does not yet support `varkwargs` fields","messagePattern":"ToArgs does not yet support `varkwargs` fields","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/monty-macros/src/to_args.rs","lineNumber":98,"sourceCode":"        }\n    });\n\n    let kw_pushes = proj_fields.iter().map(|f| {\n        let ident = &f.ident;\n        let ty = &f.ty;\n        let name_lit = LitStr::new(&ident.to_string(), ident.span());\n        match f.kind {\n            FieldKind::KwOnly => quote! {\n                __kw.push((\n                    crate::MontyObject::String(#name_lit.to_owned()),\n                    <#ty as crate::args::ToMontyObject>::into_monty_object(self.#ident),\n                ));\n            },\n            FieldKind::Varkwargs => {\n                // No caller needs this yet; reject at codegen rather than\n                // silently dropping the field.\n                let span = ident.span();\n                let err = syn::Error::new(span, \"ToArgs does not yet support `varkwargs` fields\").to_compile_error();\n                quote! { #err }\n            }\n            _ => quote! {},\n        }\n    });\n\n    Ok(quote! {\n        #[automatically_derived]\n        impl crate::args::ToArgs for #struct_ident {\n            fn to_args(\n                self,\n            ) -> (\n                ::std::vec::Vec<crate::MontyObject>,\n                ::std::vec::Vec<(crate::MontyObject, crate::MontyObject)>,\n            ) {\n                let mut __pos: ::std::vec::Vec<crate::MontyObject> = ::std::vec::Vec::new();\n                let mut __kw: ::std::vec::Vec<(crate::MontyObject, crate::MontyObject)> =\n                    ::std::vec::Vec::new();","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/pydantic/monty/blob/adc986b362e3961f407868cb118a99fe831b9e61/crates/monty-macros/src/to_args.rs#L80-L116","documentation":"A compile-time error from the `ToArgs` derive macro, emitted as a `to_compile_error!` token stream for the specific field. A field tagged `#[from_args(varkwargs)]` cannot be serialized back into call arguments by `ToArgs` — the feature is not implemented, and the macro rejects it at codegen rather than silently omitting the field from the emitted arguments.","triggerScenarios":"Deriving `ToArgs` on a struct that has a field annotated `#[from_args(varkwargs)]`.","commonSituations":"Sharing one struct definition between the inbound (`FromArgs`) and outbound (`ToArgs`) directions of a call, where the inbound side supports varkwargs but the outbound side does not.","solutions":["Remove the `#[from_args(varkwargs)]` field from the struct given to `ToArgs`, keeping it only on the `FromArgs` side (split into two structs if needed)","Represent the keyword arguments as individual `#[from_args(kw_only)]` fields, which `ToArgs` supports","If round-tripping kwargs is genuinely needed, hand-write the conversion instead of deriving"],"exampleFix":"// before\n#[derive(ToArgs)]\nstruct CallArgs {\n    x: i64,\n    #[from_args(varkwargs)]\n    kwargs: Value,\n}\n\n// after\n#[derive(ToArgs)]\nstruct CallArgs {\n    x: i64,\n}","handlingStrategy":"validation","validationCode":"// ToArgs rejects varkwargs fields — keep them off structs passed to ToArgs.\nfn to_args_compatible(kinds: &[&str]) -> bool {\n    !kinds.contains(&\"varkwargs\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Split inbound (FromArgs) and outbound (ToArgs) structs instead of sharing one type with varkwargs","Prefer explicit kw_only fields over varkwargs when round-tripping is needed","Check the ToArgs feature list in crates/monty-macros/README.md before deriving"],"tags":["rust","derive-macro","compile-time","feature-gap"],"backgroundTag":"method-not-implemented","analyzedSha":"adc986b362e3961f407868cb118a99fe831b9e61","analyzedAt":"2026-09-13T19:19:18.698Z","contentChangedAt":"2026-09-13T19:19:18.698Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}