feat(cli): auto-hydrate RecipeMetadata overlays in validate and bundle#595
Merged
mchmarny merged 2 commits intoNVIDIA:mainfrom Apr 16, 2026
Merged
Conversation
Users often pass overlay files directly to validate/bundle; detect the RecipeMetadata kind and hydrate it through the recipe builder so a separate "aicr recipe" step is not required. Shared loader in pkg/recipe.LoadFromFile is used by both commands and rejects non-RecipeResult kinds (other than empty, for backward compatibility) with a clear error pointing at the fix.
This comment was marked as resolved.
This comment was marked as resolved.
mchmarny
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Auto-hydrate
RecipeMetadataoverlay files when passed toaicr validateoraicr bundle, and reject non-RecipeResultkinds with a clear error instead of silently producing empty results.Motivation / Context
When
aicr validate --recipeoraicr bundle --recipereceives aRecipeMetadataoverlay file instead of a hydratedRecipeResult, Go's YAML unmarshaler silently succeeds — thekindfield parses correctly, butvalidationandcomponentRefsend up nil because they live underspec:in overlays vs at the top level inRecipeResult. For validate, this caused all validators to be silently skipped (selected=0). For bundle, it hit a confusing "recipe must contain at least one component reference" error.Fixes: #526
Related: N/A
Type of Change
Component(s) Affected
cmd/aicr,pkg/cli)cmd/aicrd,pkg/api,pkg/server)pkg/recipe)pkg/bundler,pkg/component/*)pkg/collector,pkg/snapshotter)pkg/validator)pkg/errors,pkg/k8s)docs/,examples/)Implementation Notes
recipe.LoadFromFile(pkg/recipe/loader.go) encapsulates recipe loading with kind detection and auto-hydration. Bothvalidate.goandbundle.gonow call this instead of rawserializer.FromFileWithKubeconfig[recipe.RecipeResult].kind: RecipeMetadatais detected, the file is re-parsed asRecipeMetadata,spec.criteriais extracted, andbuilder.BuildFromCriteriaproduces a hydratedRecipeResultin-memory. No file is written to disk.RecipeMixinand other non-RecipeResultkinds get a clear error with remediation guidance. Emptykindis allowed for backward compatibility with older files.base.yamlin practice — 1 of 58 overlays): returns a specific error explaining that only leaf overlays withspec.criteriacan be auto-hydrated.BuildFromCriteriaerrors are returned as-is (not re-wrapped) to preserve the inner error code per project conventions.initDataProvider(cmd)already runs before recipe loading in both commands, so the builder has access to embedded + external overlays.Testing
New tests:
pkg/recipe/loader_test.go— 7 cases: nonexistent file, RecipeResult passthrough, RecipeMetadata auto-hydration (verifiesKind == RecipeResultandlen(ComponentRefs) > 0), no-criteria error, RecipeMixin rejection, unknown kind rejection, empty kind backward-compatpkg/cli/validate_test.go— 6 cases: same branches exercised through the CLI harness, with positive assertions that hydrated recipes proceed to the snapshot stage (errContain: "kubernetes client")Coverage:
LoadFromFileat 88.9%;pkg/recipeat 90.7% (no regression)Risk Assessment
Rollout notes: Fully backward compatible. Existing
RecipeResultfiles load identically. The only behavioral change is thatRecipeMetadataoverlays now auto-hydrate instead of silently failing. No migration needed.Checklist
make testwith-race)make lint)git commit -S) — GPG signing infoSummary by CodeRabbit
New Features
Bug Fixes
Tests