From ae9e49e1b55a208270f23329f1e90423ca96a03e Mon Sep 17 00:00:00 2001 From: Apfelwurm Date: Sun, 11 Jan 2026 19:00:49 +0100 Subject: [PATCH 1/2] fix: breaking GetRecipeVersions when an invalid recipe version exists --- cli/app/new.go | 8 +++++++- pkg/recipe/git.go | 14 ++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cli/app/new.go b/cli/app/new.go index f6c42900..feb9ba7d 100644 --- a/cli/app/new.go +++ b/cli/app/new.go @@ -98,10 +98,14 @@ var AppNewCommand = &cobra.Command{ var recipeVersions recipePkg.RecipeVersions if recipeVersion == "" { var err error - recipeVersions, _, err = recipe.GetRecipeVersions() + var warnings []string + recipeVersions, warnings, err = recipe.GetRecipeVersions() if err != nil { log.Fatal(err) } + for _, warning := range warnings { + log.Warn(warning) + } } if len(recipeVersions) > 0 { @@ -110,6 +114,8 @@ var AppNewCommand = &cobra.Command{ recipeVersion = tag } + log.Debug(i18n.G("selected recipe version: %s (from %d available versions)", recipeVersion, len(recipeVersions))) + if _, err := recipe.EnsureVersion(recipeVersion); err != nil { log.Fatal(err) } diff --git a/pkg/recipe/git.go b/pkg/recipe/git.go index e487e011..aef62b08 100644 --- a/pkg/recipe/git.go +++ b/pkg/recipe/git.go @@ -403,15 +403,18 @@ func (r Recipe) GetRecipeVersions() (RecipeVersions, []string, error) { Branch: plumbing.ReferenceName(ref.Name()), } if err := worktree.Checkout(checkOutOpts); err != nil { - log.Debug(i18n.G("failed to check out %s in %s", tag, r.Dir)) - return err + log.Debug(i18n.G("failed to check out %s in %s: %s", tag, r.Dir, err)) + warnMsg = append(warnMsg, i18n.G("skipping tag %s: checkout failed: %s", tag, err)) + return nil } log.Debug(i18n.G("git checkout: %s in %s", ref.Name(), r.Dir)) config, err := r.GetComposeConfig(nil) if err != nil { - return err + log.Debug(i18n.G("failed to get compose config for %s: %s", tag, err)) + warnMsg = append(warnMsg, i18n.G("skipping tag %s: invalid compose config: %s", tag, err)) + return nil } versionMeta := make(map[string]ServiceMeta) @@ -419,7 +422,9 @@ func (r Recipe) GetRecipeVersions() (RecipeVersions, []string, error) { img, err := reference.ParseNormalizedNamed(service.Image) if err != nil { - return err + log.Debug(i18n.G("failed to parse image for %s in %s: %s", service.Name, tag, err)) + warnMsg = append(warnMsg, i18n.G("skipping tag %s: invalid image reference in service %s: %s", tag, service.Name, err)) + return nil } path := reference.Path(img) @@ -445,6 +450,7 @@ func (r Recipe) GetRecipeVersions() (RecipeVersions, []string, error) { return nil }); err != nil { + log.Warn(i18n.G("GetRecipeVersions encountered error for %s: %s (collected %d versions)", r.Name, err, len(versions))) return versions, warnMsg, nil } -- 2.49.0 From a51a3b57f6d4f523909025cf08aec499b788c1cd Mon Sep 17 00:00:00 2001 From: Apfelwurm Date: Sun, 11 Jan 2026 19:28:27 +0100 Subject: [PATCH 2/2] change usage of tags to recipe versions in deploy.go --- cli/app/deploy.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cli/app/deploy.go b/cli/app/deploy.go index a8b7caab..130d60f5 100644 --- a/cli/app/deploy.go +++ b/cli/app/deploy.go @@ -281,13 +281,21 @@ checkout as-is. Recipe commit hashes are also supported as values for } func getLatestVersionOrCommit(app appPkg.App) (string, error) { - versions, err := app.Recipe.Tags() + recipeVersions, warnings, err := app.Recipe.GetRecipeVersions() if err != nil { return "", err } - if len(versions) > 0 && !internal.Chaos { - return versions[len(versions)-1], nil + for _, warning := range warnings { + log.Warn(warning) + } + + if len(recipeVersions) > 0 && !internal.Chaos { + latest := recipeVersions[len(recipeVersions)-1] + for tag := range latest { + log.Debug(i18n.G("selected latest recipe version: %s (from %d available versions)", tag, len(recipeVersions))) + return tag, nil + } } head, err := app.Recipe.Head() -- 2.49.0