Skip to content

Commit

Permalink
fix: catalog conversion not handling all cases
Browse files Browse the repository at this point in the history
Fixes containers#1749

Signed-off-by: Jeff MAURY <jmaury@redhat.com>
  • Loading branch information
jeffmaury committed Sep 19, 2024
1 parent 0045a65 commit 1b20986
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/backend/src/utils/catalogUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export function sanitize(rawObject: object): ApplicationCatalog {
}

export function hasCatalogWrongFormat(raw: object): boolean {
return 'recipes' in raw && Array.isArray(raw.recipes) && !!raw.recipes.find(r => 'models' in r);
return (
!('version' in raw) || ('recipes' in raw && Array.isArray(raw.recipes) && raw.recipes.find(r => 'models' in r))
);
}

function adaptToCurrent(raw: object): object & { version: string } {
Expand All @@ -59,7 +61,7 @@ function adaptToCurrent(raw: object): object & { version: string } {
raw.recipes.forEach(recipe => {
recipe.backend = recipe.backend ?? 'llama-cpp';
recipe.recommended = recipe.recommended ?? recipe.models ?? []; // Copy models to recommended if not present
recipe.models = []; // Clear models to avoid duplication
delete recipe.models; // Clear models to avoid duplication
});
}

Expand Down

0 comments on commit 1b20986

Please sign in to comment.