{"record":{"id":"3026ec7c546027ca","repo":"OpenAPITools/openapi-generator","slug":"recallscope-key-cannot-be-empty","errorCode":null,"errorMessage":"recallScope key cannot be empty","messagePattern":"recallScope key cannot be empty","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/RecallLambda.java","lineNumber":45,"sourceCode":" * Writes rendered text that was previously cached by key.\n *\n * Syntax:\n * {{#recallScope}}key{{/recallScope}}\n */\npublic class RecallLambda implements Mustache.Lambda {\n    private final CacheContent cacheContent;\n    private final boolean clear;\n\n    public RecallLambda(CacheContent cacheContent, boolean clear) {\n        this.cacheContent = cacheContent;\n        this.clear = clear;\n    }\n\n    @Override\n    public void execute(Fragment fragment, Writer writer) throws IOException {\n        String key = fragment.execute().trim();\n        if (key.isEmpty()) {\n            throw new IllegalArgumentException(\"recallScope key cannot be empty\");\n        }\n\n        String content = this.cacheContent.contentByKey.get(key);\n        if (content == null) {\n            return;\n        }\n\n        if (this.clear) {\n            this.cacheContent.contentByKey.remove(key);\n        }\n\n        writer.write(content);\n    }\n}","sourceCodeStart":27,"sourceCodeEnd":59,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/RecallLambda.java#L27-L59","documentation":"RecallLambda (registered as 'recall' and 'recallOnce' by AbstractCSharpCodegen for C# generators) looks up previously cached content by the trimmed body of {{#recall}}key{{/recall}}. If that body trims to an empty string there is nothing to look up, and an IllegalArgumentException is thrown to stop silent no-op recalls in generated output. A missing key in the cache is NOT an error (the lambda writes nothing), only an empty key is.","triggerScenarios":"A template containing {{#recall}} {{/recall}} or {{#recallOnce}}\\n{{/recallOnce}} — whitespace-only or blank body. Typically happens when the key inside the block comes from a variable that renders empty, e.g. {{#recall}}{{someEmptyVar}}{{/recall}}.","commonSituations":"Templating cache keys off model properties that are occasionally empty (empty title, empty vendorExtension value); refactoring templates and leaving a recall block as a placeholder; copy-paste of a recall block followed by deleting its key.","solutions":["Fill the recall block with a literal key: {{#recall}}userModel{{/recall}}.","If the key is a variable, guard the block so it only renders when the variable is non-empty.","Cross-check that every {{#recall}} key matches a key used in a prior {{#cache}} block."],"exampleFix":"{{! before }}\n{{#recall}}{{modelName}}{{/recall}}\n{{! (renders empty when modelName is empty) }}\n\n{{! after }}\n{{#hasModelName}}{{#recall}}{{modelName}}{{/recall}}{{/hasModelName}}\n{{! or a literal key: }}\n{{#recall}}userModel{{/recall}}","handlingStrategy":"validation","validationCode":"# lint: reject recall blocks whose body is empty or whitespace-only\ngrep -rnE '\\{\\{#(recall|recallOnce)\\}\\}[[:space:]]*\\{\\{/' templates/ && {\n  echo \"ERROR: recall key cannot be empty\" >&2; exit 1;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use literal cache keys; wrap variable keys in a guard section so blank values skip the recall block.","Keep cache/recall key pairs in one place (a naming table) so they stay in sync."],"tags":["mustache","template","csharp","codegen","cache-lambda"],"backgroundTag":"mustache-lambda-template-error","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}