Skip to content

Commit 33358a6

Browse files
Fix model provider delete order to preserve argument order
Use a slice instead of a map to store provider entries, ensuring providers are deleted in the order specified on the command line. Map iteration order in Go is not guaranteed, which caused test flakiness. Co-authored-by: construct-agent <noreply@construct.sh>
1 parent 383368e commit 33358a6

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

frontend/cli/cmd/model_provider_delete.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,25 @@ models that depend on this provider.`,
2828
RunE: func(cmd *cobra.Command, args []string) error {
2929
client := getAPIClient(cmd.Context())
3030

31-
var modelProviderIDs = make(map[string]string)
31+
type providerEntry struct {
32+
idOrName string
33+
id string
34+
}
35+
var providers []providerEntry
3236
for _, idOrName := range args {
3337
modelProviderID, err := getModelProviderID(cmd.Context(), client, idOrName)
3438
if err != nil {
3539
return fmt.Errorf("failed to resolve model provider %s: %w", idOrName, err)
3640
}
37-
modelProviderIDs[idOrName] = modelProviderID
41+
providers = append(providers, providerEntry{idOrName: idOrName, id: modelProviderID})
3842
}
3943

4044
if !options.Force && !confirmDeletion(cmd.InOrStdin(), cmd.OutOrStdout(), "model-provider", args) {
4145
return nil
4246
}
4347

44-
for idOrName, modelProviderID := range modelProviderIDs {
48+
for _, provider := range providers {
49+
idOrName, modelProviderID := provider.idOrName, provider.id
4550
models, err := client.Model().ListModels(cmd.Context(), &connect.Request[v1.ListModelsRequest]{
4651
Msg: &v1.ListModelsRequest{
4752
Filter: &v1.ListModelsRequest_Filter{

0 commit comments

Comments
 (0)