From e11f775260e85f2335a3feb7c0ca3024788d9470 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Mon, 27 Oct 2025 20:13:46 +0100 Subject: [PATCH] fix(recipe): Prevent crash when recipe has no previous tag or release --- cli/recipe/sync.go | 13 ++++++++++--- pkg/deploy/utils.go | 6 +++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cli/recipe/sync.go b/cli/recipe/sync.go index 5e474743..f8fc19f6 100644 --- a/cli/recipe/sync.go +++ b/cli/recipe/sync.go @@ -42,7 +42,8 @@ local file system.`), ValidArgsFunction: func( cmd *cobra.Command, args []string, - toComplete string) ([]string, cobra.ShellCompDirective) { + toComplete string, + ) ([]string, cobra.ShellCompDirective) { switch l := len(args); l { case 0: return autocomplete.RecipeNameComplete() @@ -131,10 +132,16 @@ likely to change. log.Fatal(err) } - latestRelease := tags[len(tags)-1] + latestRelease := "0.0.0+0.0.0" + if len(tags) > 0 { + latestRelease = tags[len(tags)-1] + } changesTable.Headers(i18n.G("SERVICE"), latestRelease, i18n.G("PROPOSED CHANGES")) - latestRecipeVersion := versions[len(versions)-1] + latestRecipeVersion := latestRelease + if len(versions) > 0 { + latestRecipeVersion = versions[len(versions)-1] + } allRecipeVersions := catl[recipe.Name].Versions for _, recipeVersion := range allRecipeVersions { if serviceVersions, ok := recipeVersion[latestRecipeVersion]; ok { diff --git a/pkg/deploy/utils.go b/pkg/deploy/utils.go index 99c730f3..0082a4f6 100644 --- a/pkg/deploy/utils.go +++ b/pkg/deploy/utils.go @@ -282,7 +282,11 @@ func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *com } imageBaseName := reference.Path(imageParsed) - imageTag := imageParsed.(reference.NamedTagged).Tag() + namedTag, ok := imageParsed.(reference.NamedTagged) + if !ok { + continue + } + imageTag := namedTag.Tag() existingImageVersion, ok := newImages[imageBaseName] if !ok {