lnvps_api_common::CustomVmSpec (lnvps_api_common/src/model.rs:741-802) and ApiCustomVmRequest (lnvps_api/src/api/model.rs:747-791) are two wire types for the same custom-VM body, each with its own conversion to VmCustomTemplate. Two conversions for one shape will drift.
Collapse the customer one onto CustomVmSpec: POST /api/v1/vm/custom-template deserializes CustomVmSpec and calls to_template(), and the From<ApiCustomVmRequest> for VmCustomTemplate impl goes away (~45 lines).
This also fixes silent defaulting on the customer path. Today ApiCustomVmRequest uses filter_map(|s| s.parse().ok()) for cpu_feature and unwrap_or_default() for cpu_mfg/cpu_arch (lnvps_api/src/api/model.rs:768-787), so a typo'd cpu_arch becomes "any" and the customer gets a machine they did not ask for. CustomVmSpec::to_template() errors instead, which the route should surface as a 400.
Behaviour change to call out: requests that today succeed with a misspelled enum value would start failing with 400. Worth a note in API_CHANGELOG.md, and Marta should know if the site ever sends anything other than the exact enum spellings.
Found in review of #335 / PR 337.
lnvps_api_common::CustomVmSpec(lnvps_api_common/src/model.rs:741-802) andApiCustomVmRequest(lnvps_api/src/api/model.rs:747-791) are two wire types for the same custom-VM body, each with its own conversion toVmCustomTemplate. Two conversions for one shape will drift.Collapse the customer one onto
CustomVmSpec:POST /api/v1/vm/custom-templatedeserializesCustomVmSpecand callsto_template(), and theFrom<ApiCustomVmRequest> for VmCustomTemplateimpl goes away (~45 lines).This also fixes silent defaulting on the customer path. Today
ApiCustomVmRequestusesfilter_map(|s| s.parse().ok())forcpu_featureandunwrap_or_default()forcpu_mfg/cpu_arch(lnvps_api/src/api/model.rs:768-787), so a typo'dcpu_archbecomes "any" and the customer gets a machine they did not ask for.CustomVmSpec::to_template()errors instead, which the route should surface as a400.Behaviour change to call out: requests that today succeed with a misspelled enum value would start failing with
400. Worth a note inAPI_CHANGELOG.md, and Marta should know if the site ever sends anything other than the exact enum spellings.Found in review of #335 / PR 337.