{"record":{"id":"b27fc050bf642666","repo":"quarkusio/quarkus","slug":"recipe-name-is-required","errorCode":null,"errorMessage":"Recipe name is required","messagePattern":"Recipe name is required","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/QuarkusUpdateRecipe.java","lineNumber":52,"sourceCode":"    public QuarkusUpdateRecipe addOperation(RewriteOperation operation) {\n        this.operations.add(operation);\n        return this;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public QuarkusUpdateRecipe addRecipes(List<Object> recipe) {\n        for (Object r : recipe) {\n            if (r instanceof Map) {\n                addRecipe((Map<String, Object>) r);\n            }\n        }\n        return this;\n    }\n\n    public QuarkusUpdateRecipe addRecipe(Map<String, Object> recipe) {\n        Objects.requireNonNull(recipe, \"recipe is required\");\n        if (!recipe.containsKey(\"name\") || !(recipe.get(\"name\") instanceof String)) {\n            throw new IllegalArgumentException(\"Recipe name is required\");\n        }\n        // some YAML documents might not be recipes. For instance, they could be categories.\n        if (!recipe.containsKey(\"type\") || !recipe.get(\"type\").toString().endsWith(\"/recipe\")) {\n            return this;\n        }\n        this.recipes.add(recipe);\n        return this;\n    }\n\n    public BuildTool getBuildTool() {\n        return buildTool;\n    }\n\n    public List<RewriteOperation> getOperations() {\n        return operations;\n    }\n\n    public List<Map<String, Object>> getRecipes() {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/QuarkusUpdateRecipe.java#L34-L70","documentation":"QuarkusUpdateRecipe.addRecipe() validates that each recipe map parsed from a rewrite update YAML document has a 'name' entry whose value is a String. If the name key is missing or is not a String, the method throws IllegalArgumentException(\"Recipe name is required\"). This guard exists because rewrite YAML documents may contain non-recipe entries (categories), and downstream processing keys recipes by name.","triggerScenarios":"Calling addRecipe(Map<String, Object> recipe) with a map lacking the \"name\" key, or where recipe.get(\"name\") is not a String (e.g. a number, list, or nested map). Happens when addRecipes iterates YAML documents that were expected to be recipe definitions.","commonSituations":"A hand-written or third-party rewrite recipe YAML omits the top-level 'name' field; a YAML document is actually a category (no name) and is fed through addRecipe directly instead of being filtered; YAML quoting/typing makes the name parse as a non-string (e.g. an unquoted numeric name).","solutions":["Add a top-level 'name' string field to the recipe map/YAML document before passing it to addRecipe.","Ensure the name value is a plain string in YAML (quote it if it looks numeric or special).","If the document is a category rather than a recipe, add 'type: <x>/recipe' checks or skip it before calling addRecipe."],"exampleFix":"// before\nMap<String, Object> recipe = Map.of(\"type\", \"org.openrewrite.java.Recipe\");\nquarkusUpdateRecipe.addRecipe(recipe);\n// after\nMap<String, Object> recipe = Map.of(\"name\", \"com.example.MyRecipe\", \"type\", \"org.openrewrite.java.Recipe\");\nquarkusUpdateRecipe.addRecipe(recipe);","handlingStrategy":"validation","validationCode":"if (recipe == null || !(recipe.get(\"name\") instanceof String name) || name.isBlank()) {\n    throw new IllegalArgumentException(\"Recipe name is required before addRecipe()\");\n}","typeGuard":"static boolean hasStringName(Map<String, Object> recipe) {\n    return recipe != null && recipe.get(\"name\") instanceof String s && !s.isBlank();\n}","tryCatchPattern":"try {\n    quarkusUpdateRecipe.addRecipe(recipe);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Skipping malformed recipe document: \" + e.getMessage());\n}","preventionTips":["Always include a top-level string 'name' in every recipe map/YAML document.","Quote recipe names in YAML so numeric-looking names stay strings.","Filter category documents (no type ending in '/recipe') before calling addRecipe.","Unit-test recipe YAML files with a schema check in CI."],"tags":["validation","yaml","rewrite-recipes"],"backgroundTag":"missing-required-argument","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}