fix(coderd): avoid fetching extra parameters for a preset (#16642)

This pull request fixes a bug in presets and adds tests to ensure it
doesn't happen again.
Due to an oversight in refactoring, we returned extra and incorrect
parameters from other presets in the same template version when calling
`/templateversions/{templateversion}/presets`.
This commit is contained in:
Sas Swart
2025-02-20 09:58:04 +02:00
committed by GitHub
parent 9469b78290
commit dedc32fb1a
2 changed files with 115 additions and 41 deletions
+4
View File
@@ -45,6 +45,10 @@ func (api *API) templateVersionPresets(rw http.ResponseWriter, r *http.Request)
Name: preset.Name,
}
for _, presetParam := range presetParams {
if presetParam.TemplateVersionPresetID != preset.ID {
continue
}
sdkPreset.Parameters = append(sdkPreset.Parameters, codersdk.PresetParameter{
Name: presetParam.Name,
Value: presetParam.Value,