From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 3152F1FF09F for ; Thu, 03 Sep 2026 20:51:12 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C3821214DD; Thu, 03 Sep 2026 20:51:11 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 03 Sep 2026 20:51:08 +0200 Message-Id: Subject: Re: [PATCH proxmox v5 03/21] api-macro: support #[state] attribute for state injection From: =?utf-8?q?Michael_K=C3=B6ppl?= To: "Lukas Wagner" , X-Mailer: aerc 0.22.0 References: <20260903111609.267762-1-l.wagner@proxmox.com> <20260903111609.267762-4-l.wagner@proxmox.com> In-Reply-To: <20260903111609.267762-4-l.wagner@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1788461465547 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.794 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: EPY3V3CJQ5CTTUXM2KUJRHUFEQFHGIZ2 X-Message-ID-Hash: EPY3V3CJQ5CTTUXM2KUJRHUFEQFHGIZ2 X-MailFrom: m.koeppl@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu Sep 3, 2026 at 1:15 PM CEST, Lukas Wagner wrote: [snip] > fn handle_function_signature(method_info: &mut MethodInfo) -> Result { > + let state_params =3D take_state_attributes(&mut method_info.func.sig= ); > + > let sig =3D &method_info.func.sig; > =20 > let mut api_method_param =3D None; > @@ -382,7 +474,11 @@ fn handle_function_signature(method_info: &mut Metho= dInfo) -> Result =20 > let mut param_list =3D Vec::<(FieldName, ParameterType)>::new(); > =20 > - for input in sig.inputs.iter() { > + for (index, input) in sig.inputs.iter().enumerate() { > + if state_params.contains(&index) { > + continue; > + } Even though it's not something that would likely occur (since this would e.g. occur if someone used `#[state] _: PdmApplication` or something similar), this would not show any errors from checking the types anymore, no? Because the second [loop] expects errors to be handled [here], but for state params, this check would simply be skipped. Hope I'm not missing something here, but this would probably hide errors. > + > let (pat_type, pat) =3D match check_input_type(input) { > Ok(input) =3D> input, > Err(err) =3D> { [here] > @@ -410,7 +506,7 @@ fn handle_function_signature(method_info: &mut Method= Info) -> Result }; > } > =20 > - for input in sig.inputs.iter() { > + for (index, input) in sig.inputs.iter().enumerate() { > let (pat_type, pat) =3D match check_input_type(input) { > Ok(input) =3D> input, > Err(_err) =3D> continue, // we already produced errors above= , [loop] > @@ -421,17 +517,20 @@ fn handle_function_signature(method_info: &mut Meth= odInfo) -> Result // values, and our 2 fixed function parameters: `&ApiMethod` and= `&mut dyn RpcEnvironment`. > // > // Our strategy is as follows: > - // 1) See if the parameter name also appears in the input sc= hema. In this case we > + // 1) See if the parameter was marked with `#[state]`. Such = parameters are filled in [snip]